我正在構建針對一些傳統的第三方庫的應用程序,並且存在鏈接階段的問題。我試圖用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,所以我希望這只是我的一些無知。任何想法如何解決這些問題?