gpt4 book ai didi

c++ - 警告在 WDK 构建 ("LNK4217: locally defined symbol _ imported in function _"中链接 boost 库)

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:37:20 24 4
gpt4 key购买 nike

我正在使用 WDK 构建以下示例消耗 boost 的用户模式应用程序,但是在链接我之前使用 bootstrap 和 .\bjam 从同一终端构建的 boost 库时出现以下错误窗口。

IIUC,MSDN说这是因为(严重损坏的)函数——看起来是 C++ std lib 函数——被标记为 DLL 导入,但我有一个本地定义。这怎么发生的?有办法解决这个问题吗?

另请参阅: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 ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ (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)" (??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ)

最佳答案

您在链接中明确包含 ..\boost_1_40_0\stage\lib\libboost_program_options-vc100-mt.lib。

你应该让 boost auto_link 东西配置做正确的#pragma comment(lib, ...) 东西确保你引入正确的库并正确设置链接器搜索路径。最有可能的是 boost 库和您的代码链接到不同的运行时库。

关于c++ - 警告在 WDK 构建 ("LNK4217: locally defined symbol _ imported in function _"中链接 boost 库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1570516/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com