我尝试编译 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/