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