linux平台下使用boost库


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<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)?.

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<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type>, void>::type*) [with Source = std::basic_string<char, std::char_traits<ch`ar>, std::allocator<char> >]?

上面出现"?"等乱码看不出错误是什么,修改xshell default language 成utf-8,

g++ main.cpp SourceLine.cpp FileTravel.cpp -lboost_filesystem -lboost_thread

运行正常。

3.总结:boost是个好库,但g++链接相对繁锁,用哪个库就要指定哪个库的样子,到底哪些库需要这个指定,待时间用长了再结论。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章