1. 下载boost编译后,boost头文件最好拷到/usr/include下,或者在/usr/include下有链接。
stage/lib/libboost_*中的库文件最好拷到/usr/lib中。
这样用g++运行时,可以不用指定-I$BOOST_INCLUDE和-L$BOOST_LIB.
2. 运行
g++ main.cpp SourceLine.cpp FileTravel.cpp -I$BOOST_INCLUDE -L$BOOST_LIB -lboost_filesystem
出现如下错误:
FileTravel.cpp: In member function ?.oid FileTravel::GetSubfiles(std::vector<:basic_string std::char_traits>, std::allocator >, std::allocator<:basic_string std::char_traits>, std::allocator > > >&)?.
FileTravel.cpp:27: error: invalid conversion from ?.ool (*)(const std::string&)?.to ?oid*?
FileTravel.cpp:27: error: initializing argument 2 of ?.oost::filesystem3::path::path(const Source&, typename boost::enable_if<:filesystem3::path_traits::is_pathable boost::decay>::type>, void>::type*) [with Source = std::basic_string, std::allocator >]?
上面出现"?"等乱码看不出错误是什么,修改xshell default language 成utf-8,
g++ main.cpp SourceLine.cpp FileTravel.cpp -lboost_filesystem -lboost_thread
运行正常。
3.总结:boost是个好库,但g++链接相对繁锁,用哪个库就要指定哪个库的样子,到底哪些库需要这个指定,待时间用长了再结论。