链接通过SConstruct提振 [英] Linking to boost through SConstruct
问题描述
我想对使用升压的文件/目录操作的一个跨平台的项目。我一直在使用Visual Studio,但为了编译在Linux上,我已经决定改用SConstruct。
我不能[正确?]链接库文件系统不过。
我的SConstruct文件如下:
vLibs = [
libboost_system-VC100-MT-1_44.lib',
libboost_filesystem-VC100-MT-1_44.lib'];
#LIBS = vLibs,
ENV =环境();env.AppendUnique(CXXFLAGS =斯普利特(/ EHSC));
env.Append(CPPPATH =C:\\\\程序文件(x86)\\\\ \\\\提振boost_1_44]);
env.Append(LIBPATH =C:\\\\程序文件(x86)\\\\ \\\\提振\\\\ boost_1_44 LIB]);env.Program(水珠('TEST.CPP'),LIBS = vLibs)
我不断收到这样的错误
test.obj:错误LNK2019:无法解析的外部符号类boost ::系统:: error_category常量和放大器; __cdecl的boost ::系统:: generic_category(无效)(generic_category @ @系统提升@@ YAAEBVerror_category @ 12 @? XZ)函数引用无效__cdecl的boost ::系统::`为'posix_category''(空)动态初始化(?? __ Eposix_category @ @系统提升@@ YAXXZ)
块引用>如果我用Visual Studio中,我得到类似的错误:
错误2错误LNK2001:无法解析的外部符号类boost ::系统:: error_category常量和放大器; __cdecl的boost ::系统:: generic_category(无效)(generic_category @ @系统提升@@ YAABVerror_category @ 12 @ XZ?) T:\\ VS \\ TEMP \\ test.obj温度
块引用>直到我添加库项目,在此之后,错误消失,它编译罚款(视觉工作室不SConstruct)。
我试过图书馆(共享/非共享/运行时共享/运行时不共享/调试)的每个组合,但我总是得到同样的错误。
我一直在寻找过去6+小时的答案,所以我很感谢任何帮助。
请注意:我不使用autolinking(#定义BOOST_ALL_NO_LIB),因为GCC不支持)
下面是使用SCons的输出:
scons的:读SConscript文件...
scons的:读完SConscript文件。
scons的:建筑的目标...
链接/ NOLOGO /OUT:build\\test.exe/ LIBPATH:C:\\ Program Files文件(x86)的\\提升\\ boost_1_44 \\ LIBlibboost_system-VC100-MT-1_44.lib libboost_filesystem-VC100-MT-1_44.lib构建\\ test.obj
test.obj:错误LNK2019:无法解析的外部符号类boost ::系统:: error_category常量和放大器; __cdecl的boost ::系统:: generic_category(无效)(generic_category @ @系统提升@@ YAAEBVerror_category @ 12 @ XZ?)引用在功能上无效__cdecl的boost ::系统::`为'posix_category''(空)动态初始化(?? __Eposix_category @ @系统提升@@ YAXXZ)
test.obj:错误LNK2019:无法解析的外部符号类boost ::系统:: error_category常量和放大器; __cdecl的boost ::系统:: system_category(无效)(system_category @ @系统提升@@ YAAEBVerror_category @ 12 @ XZ?)引用在功能上无效__cdecl的boost ::系统::`动态初始化为'native_ecat''(空)(?? __Enative_ecat @ @系统提升@@ YAXXZ)
建立\\ test.exe的:致命错误LNK1120:2无法解析的外部
scons的:*** [建\\ test.exe的]错误1120
scons的:建筑终止,因为错误的。
解决方案我得到了完全相同的错误,直到我重建的地址模式升压= 64参数的bjam
I'm trying to work on a cross-platform project that uses boost for the file/directory operations. I've been using visual studio, but in order to compile on linux, I've decided to switch to SConstruct.
I cannot [correctly?] link to the filesystem library however.
my SConstruct file is as follow:
vLibs = [ 'libboost_system-vc100-mt-1_44.lib', 'libboost_filesystem-vc100-mt-1_44.lib']; # LIBS=vLibs, env = Environment(); env.AppendUnique(CXXFLAGS=Split("/EHsc")); env.Append(CPPPATH = ["C:\\Program Files (x86)\\boost\\boost_1_44"]); env.Append(LIBPATH = ["C:\\Program Files (x86)\\boost\\boost_1_44\\lib"]); env.Program( Glob('test.cpp'),LIBS=vLibs)
I keep getting errors like
test.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
If I use visual studio, I get similar errors:
Error 2 error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ) T:\VS\temp\test.obj temp
Until I add the libraries to the project, after which the errors go away and it compiles fine (in visual studio not SConstruct).
I've tried every combination of the libraries (shared/unshared/runtime-shared/runtime-unshared/debug), but I always get the same errors.
I've been searching for an answer for the last 6+ hours, so I'm grateful for any help.
NOTE: I'm not using autolinking (#define BOOST_ALL_NO_LIB) because gcc doesn't support it)
Here's the output of Scons:
scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... link /nologo /OUT:build\test.exe "/LIBPATH:C:\Program Files (x86)\boost\boost_1_44\lib" libboost_system-vc100-mt-1_44.lib libboost_filesystem-vc100-mt-1_44.lib build\test.obj test.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (?? __Eposix_category@system@boost@@YAXXZ) test.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (?? __Enative_ecat@system@boost@@YAXXZ) build\test.exe : fatal error LNK1120: 2 unresolved externals scons: *** [build\test.exe] Error 1120 scons: building terminated because of errors.
解决方案I got the exact same error until I rebuilt boost with the address-model=64 parameter to bjam
这篇关于链接通过SConstruct提振的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!