gpt4 book ai didi

c++ - 对 "boost::system::system_category()"的 undefined reference

转载 作者:行者123 更新时间:2023-11-30 04:13:40 29 4
gpt4 key购买 nike

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 中该在哪里做!
我已经花了一天时间来解决这个问题。感谢您的帮助!

最佳答案

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

enter image description here enter image description here enter image description here enter image description here

此外,您可以添加一些自定义变量来简化调试/发布和 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)
{

}

关于c++ - 对 "boost::system::system_category()"的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19316193/

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