2
我正在用WDK構建下面的示例助推消費用戶模式應用程序,但出現以下錯誤當使用bootstrap和。\ bjam從同一個終端窗口創建的boost庫連接時。在WDK版本(「LNK4217:本地定義的符號_在函數_中導入」)中鏈接boost lib的警告
IIUC,MSDN表示這是因爲(看起來是C++ std lib函數)(可怕的mangled函數)被標記爲DLL導入,但我有一個本地定義。這怎麼發生的?有沒有辦法解決這個問題?
另請參閱:a loosely related question。
C:\exp>more exp.cpp
#pragma warning(disable: 4512)
#include <boost/program_options.hpp>
int __cdecl main() {
boost::program_options::options_description desc("Allowed options");
return 0;
}
C:\exp>more sources
TARGETNAME=exp
TARGETTYPE=PROGRAM
USE_MSVCRT=1
USE_STL=1
USE_NATIVE_EH=1
MSC_WARNING_LEVEL=/W4 /WX
_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
INCLUDES=..\boost_1_40_0
SOURCES=exp.cpp
UMTYPE=console
UMBASE=0x400000
TARGETLIBS = $(SDK_LIB_PATH)\ws2_32.lib ..\boost_1_40_0\stage\lib\libboost_program_options-vc100-mt.lib
C:\exp>build
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.0\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Wed Oct 14 17:34:23 2009
BUILD: Examining c:\exp directory for files to compile.
c:\exp
Invalidating OACR warning log for 'root:x86chk'
BUILD: Saving c:\winddk\7600.16385.0\build.dat...
BUILD: Compiling and Linking c:\exp directory
Configuring OACR for 'root:x86chk' - <OACR on>
_NT_TARGET_VERSION SET TO WINXP
Linking Executable - objchk_win7_x86\i386\exp.exe
1>errors in directory c:\exp
1>link : error LNK1218: warning treated as error; no output file generated
BUILD: Finish time: Wed Oct 14 17:34:44 2009
BUILD: Done
1 executable built - 1 Warning - 1 Error
C:\exp>more *wrn
1>warnings in directory c:\exp
1>c:\exp\libboost_program_options-vc100-mt.lib(options_description.obj): warning LNK4217: locally defined symbol [email protected][email protected]@[email protected]@@[email protected]@[email protected] (public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)) imported in function "public: virtual __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >(void)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected])
你的答案幫助我通過了這個第一個構建問題 - 謝謝 - 但現在鏈接器抱怨無法找到libboost_program_options-vc90-mt-s-1_40.lib,而我只有* -vc100- *文件 - 奇怪,因爲在嘗試構建我的應用程序之前,我從完全相同的(Visual C 9.0)終端窗口構建了boost。有任何想法嗎? bootstrap/bjam是否將自己配置爲使用不同的VC?任何方式來確定和/或控制它? – Yang 2009-10-17 21:26:00
這解釋了爲什麼運行時庫不同以及爲什麼看到錯誤。 是的,boost構建系統將檢查您的註冊表並查看您已安裝的編譯器。如果你想用msvc 9建立boost,用「toolset = msvc-9.0」調用bjam。由此產生的庫應該有vc90的名字。您也可以檢查boost-build文檔。 如果您希望在不使用命令行選項的情況下重現此功能,您可以添加如下內容:「using msvc:9.0;」到user-config.jam。 – janm 2009-10-19 23:25:35