【问题标题】:Undefined reference to "boost::system::system_category()"对“boost::system::system_category()”的未定义引用
【发布时间】:2013-10-19 10:03:12
【问题描述】:
obj\Debug\src\SQLite3DB.o||In function _static_initialization_and_destruction_0:|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|222|undefined reference to boost::system::generic_category()|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|223|undefined reference to boost::system::generic_category()|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|224|undefined reference to boost::system::system_category()|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 4 seconds) ===|

以上是我在项目中包含boost/filesystem.hpp 后的完整错误消息。我看到一些帖子说添加 -lboost_system 可能会解决这个问题,但我不知道在 CodeBlocks 中的哪里可以做到这一点!
我已经花了一天的时间来解决这个问题。感谢您的帮助!

【问题讨论】:

标签: c++ boost codeblocks undefined-reference


【解决方案1】:

右键项目名称;单击“构建选项...”;转到“链接器设置”;点击“添加”;找到库并添加它。

此外,您可以添加一些自定义变量来简化调试/发布和 32/64 位目标选项的管理。我会把它留给你。


编辑

这是来自error_code.hpp的错误代码:

# ifndef BOOST_SYSTEM_NO_DEPRECATED
    inline const error_category &  get_system_category() { return system_category(); }
    inline const error_category &  get_generic_category() { return generic_category(); }
    inline const error_category &  get_posix_category() { return generic_category(); }
    static const error_category &  posix_category = generic_category();
    static const error_category &  errno_ecat     = generic_category();
    static const error_category &  native_ecat    = system_category();
# endif

如您所见,定义BOOST_SYSTEM_NO_DEPRECATED 将禁用它。我已经测试过了,它可以工作。这样编译:

#define BOOST_SYSTEM_NO_DEPRECATED
#include <boost/system/error_code.hpp>

int main(void)
{

}

【讨论】:

  • ..\..\..\..\Boost\1_54_0\VC\11.0\bin.v2\libs\system\build\msvc-11.0\debug\link-static\threading- multi\libboost_system-vc110-mt-gd-1_54.lib - 在我将它添加到链接器设置之后它仍然得到相同的错误!
猜你喜欢
  • 2015-04-09
  • 2017-02-25
  • 1970-01-01
  • 2012-06-30
  • 2021-03-30
  • 1970-01-01
  • 2019-07-05
  • 2016-05-26
  • 2012-11-08
相关资源
最近更新 更多