通过SConstruct链接到boost [英] Linking to boost through SConstruct
问题描述
我试图在一个跨平台项目中使用boost来执行文件/目录操作。我一直在使用visual studio,但为了在linux上编译,我决定切换到SConstruct。
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.
我的SConstruct文件如下:
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)
$ b b
我不断收到类似
I keep getting errors like
test.obj:error LNK2019:unresolved external symbolclass boost :: system :: error_category函数void __cdecl boost :: system ::`动态初始化器中引用的posix_category的引用的const& __cdecl boost :: system :: generic_category(void)(?generic_category @ system @ boost @@ YAAEBVerror_category @ (void)(?? __ Eposix_category @ system @ boost @@ YAXXZ)
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)
如果我使用visual studio,
If I use visual studio, I get similar errors:
错误2错误LNK2001:未解析的外部符号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
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
直到我将库添加到项目,之后错误消失,它编译良好(在visual studio不SConstruct)。
Until I add the libraries to the project, after which the errors go away and it compiles fine (in visual studio not SConstruct).
我试过库的每个组合(共享/非共享/运行时共享/ runtime-unshared / debug),但我总是得到相同的错误。
I've tried every combination of the libraries (shared/unshared/runtime-shared/runtime-unshared/debug), but I always get the same errors.
我一直在寻找最近6小时内的答案,所以非常感谢您的帮助。
I've been searching for an answer for the last 6+ hours, so I'm grateful for any help.
注意:我没有使用自动链接(#define BOOST_ALL_NO_LIB),因为gcc不支持它)
NOTE: I'm not using autolinking (#define BOOST_ALL_NO_LIB) because gcc doesn't support it)
以下是Scons的输出:
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.
推荐答案
bjam
这篇关于通过SConstruct链接到boost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!