简体   繁体   English

提升链接错误

[英]Boost linking error

So, I'm trying to use boost.process library. 因此,我正在尝试使用boost.process库。 I downloaded package from this location , copied includes from boost subdirectory into /usr/include/boost , wrote a simple code: 我从此位置下载了软件包,将包括的内容从boost子目录复制到了/ usr / include / boost ,并编写了一个简单的代码:

    namespace bp = ::boost::process;
    std::string execApp = "make";
    std::vector<std::string> args;
    args.push_back("-C ../build");

    bp::context ctx;
    ctx.stdout_behavior = bp::silence_stream();

    bp::child buildProcess = bp::launch(execApp, args, ctx);

It compiles but fails at linker: 它可以编译,但在链接器上失败:

CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::get_system_category()'
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `boost::process::detail::file_handle::posix_remap(int)':
/usr/include/boost/process/detail/file_handle.hpp:264: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/process/detail/file_handle.hpp:269: undefined reference to `boost::system::get_system_category()'
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `boost::process::detail::file_handle::posix_dup(int, int)':
/usr/include/boost/process/detail/file_handle.hpp:295: undefined reference to `boost::system::get_system_category()'
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `pipe':
/usr/include/boost/process/detail/pipe.hpp:86: undefined reference to `boost::system::get_system_category()'
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o:/usr/include/boost/process/detail/posix_ops.hpp:202: more undefined references to `boost::system::get_system_category()' follow
collect2: ld returned 1 exit status

I've linked such libraries: filesystem system date_time 我已经链接了以下库: filesystem system date_time

You might want to see the last answer here. 您可能想在这里看到最后一个答案

I had a very similar problem and found this post while searching. 我有一个非常类似的问题,并且在搜索时发现了这篇文章。 I managed to solved the problem after much more searching, so I post it here for other people. 经过更多搜索之后,我设法解决了该问题,因此我将其发布在这里供其他人使用。

I had to link to the proper library this way: g++ boost_example.cpp -o run -lboost_filesystem-mt http://linux.overshoot.tv/ticket/127 我必须以这种方式链接到适当的库:g ++ boost_example.cpp -o运行-lboost_filesystem-mt http://linux.overshoot.tv/ticket/127

The real problem is that the boost documentation is lacking and does not say which library to link to. 真正的问题是,boost文档不足,没有说明要链接到哪个库。 See: http://linux.overshoot.tv/ticket/129 请参阅: http//linux.overshoot.tv/ticket/129

Anyway, to use boost/file_system, link to: -lboost_filesystem-mt . 无论如何,要使用boost / file_system,请链接至:-lboost_filesystem-mt。

See also: http://ubuntuforums.org/showthread.php?t=244593 另请参阅: http : //ubuntuforums.org/showthread.php?t=244593

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM