C++ 使用 wofstream 时未解析的外部符号

C++ Unresolved external symbol when using wofstream

本文关键字:外部 符号 使用 wofstream C++      更新时间:2023-10-16

我正在从批处理文件编译和链接此源代码,我现在正在导入的库MSVCRT.LIB Kernel32.lib User32.lib
代码一直有效,直到我包含string iostreamfstream并创建一些wofstream对象。这时链接器向我展示了一大堆未解析的符号,其中包括:

std::_BADOFF
static class std::locale::id std::codecvt
std::_Xout_of_range
std::_Fiopen
std::basic_streambuf
std::char_traits
std::basic_ios
std::locale::id::operator unsigned _int64

所以我想知道我可能错过了哪些图书馆。在链接器中,我指定了/nodefaultlib选项,以便我可以决定使用哪些库,但现在我遇到了这个问题,找不到这些标准函数的库。

简短:MSVCPRT.LIB

这些符号在运行时库中定义C++。虽然你确实与MSVCRT.lib链接(注意没有字母P),但这只是C,而不是C++运行时。

这是MSDN页面,您可能会找到有用的 http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx