我正在构建针对一些传统的第三方库的应用程序,并且存在链接阶段的问题。我试图用Visual Studio 9进行编译。我的编译命令是:C++链接器无法解析的外部符号
cl -DNT40 -DPOMDLL -DCRTAPI1=_cdecl
-DCRTAPI2=cdecl -D_WIN32 -DWIN32 -DWIN32_LEAN_AND_MEAN -DWNT -DBYPASS_FLEX -D_INTEL=1 -DIPLIB=none -I. -I"D:\src\include" -I"C:\Program Files\Microsoft Visual Studio
9.0\VC\include" -c -nologo -EHsc -W1 -Ox -Oy- -MD mymain.c
代码干净地编译。链接命令是:
是我得到的错误是:
app_main.obj : error LNK2019:
unresolved external symbol
"_\_declspec(dllimport) public: void
__thiscall std::locale::facet::_Register(void)"
([email protected]@[email protected]@@QAEXXZ)
referenced in function "class
std::ctype<char> const & __cdecl
std::use_facet<class std::ctype<char>
(class std::locale const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z)
app_main.obj : error LNK2019:
unresolved external symbol
"__declspec(dllimport) public: static
unsigned int __cdecl
std::ctype<char>::_Getcat(class
std::locale::facet const * *)"
([email protected][email protected]@[email protected]@[email protected]@[email protected]@Z)
referenced in function "class
std::ctype<char> const & __cdecl
std::use_facet<class std::ctype<char>
(class std::locale const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z)
app_main.obj : error LNK2019:
unresolved external symbol
"__declspec(dllimport) public: static
unsigned int __cdecl
std::ctype<unsigned
short>::_Getcat(class
std::locale::facet const * *)"
([email protected][email protected]@[email protected]@[email protected]@[email protected]@Z)
referenced in function "class
std::ctype<unsigned short> const &
__cdecl std::use_facet<class std::ctype<unsigned short> >(class
std::locale const &)"
([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z)
mymain.exe : fatal error LNK1120: 3
unresolved externals
注意,这些错误是从旧的代码来了,不是我的代码 - app_main.obj是部分遗留代码,而mymain.c是我的源代码。我已经做了一些搜索,并且我读过的内容说这种类型的错误是由于我的代码和我链接到的库之间的-MD开关不匹配造成的。由于我正在处理遗留代码,所以解决方案必须来自我的环境。自从我完成C++工作已经很长时间了,甚至更长的时间,因为我已经使用了Visual Studio,所以我希望这只是我的一些无知。任何想法如何解决这些问题?