c++ - Boost 文件系统教程无法编译

标签 c++ boost codeblocks

我尝试编译 boost 文件系统 tutorial在代码中:: block 它出现了这些错误

Linking console executable: bin\Debug\Boost fs tut1.exe
obj\Debug\main.o: In function `_static_initialization_and_destruction_0':
D:/Documents/Coding/Libs/boost/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
D:/Documents/Coding/Libs/boost/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
D:/Documents/Coding/Libs/boost/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
obj\Debug\main.o: In function `ZN5boost11filesystem34path7codecvtEv':
D:/Documents/Coding/Libs/boost/boost/filesystem/v3/path.hpp:388: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
obj\Debug\main.o: In function `convert':
D:/Documents/Coding/Libs/boost/boost/filesystem/v3/path_traits.hpp:113: undefined reference to `boost::filesystem3::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
obj\Debug\main.o: In function `file_size':
D:/Documents/Coding/Libs/boost/boost/filesystem/v3/operations.hpp:366: undefined reference to `boost::filesystem3::detail::file_size(boost::filesystem3::path const&, boost::system::error_code*)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings

我在 Windows 7 上使用 Code::Blocks 版本 10.5、G++ 版本 4.4.1 和 boost 版本 1.47 运行它

最佳答案

Boost.System 的一大块存在于单独构建的库中。并不是所有的头文件。您必须构建它并链接到它。

参见 Linking Boost Library in Linux例如 (linux) 和 http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef (代码块)

希望这对您有所帮助!

关于c++ - Boost 文件系统教程无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8075315/

相关文章:

c++ - OpenCV - 查找或访问未被 bg 包围的形状轮廓,仅由轮廓分隔

c++ - std::mem_fn 返回的函数对象是否需要 const 重载

c++ - STL 容器性能概述

c++ - 从 boost::multi_index 的迭代器推导出 Tag

compiler-errors - 在代码:Blocks (WIndows 10 )中安装GTK时出现问题

c++ - 超过 64 位时的未定义行为

c++ - 如何在没有数据复制的情况下从指针创建 Eigen VectorXd 对象

c++ - 用 0 重写文件。我究竟做错了什么?

c++ - 在代码块上安装 CppCheck

c++ - CImg: 无法识别 jpg 格式