我尝试在Code :: Blocks中编译boost文件系统tutorial
而这些错误

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(CodeBlocks)

希望这可以帮助!

10-08 11:36