我试图用升压与C没有安装库++应用程序时,在Ubuntu 12.10得到这个错误:
[email protected]:~/foo8/33_parse_file$ g++ -o s s.cpp
s.cpp:3:29: fatal error: boost/foreach.hpp: No such file or directory
compilation terminated.
从这个代码:
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
using namespace std;
int main(){
cout << "hi";
}
我在Ubu ntu 12.10所以我安装了这样的升压:
sudo apt-get install libboost-all-dev
然后在重新编译,它的工作,现在我可以使用提升!
#include <iostream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
using namespace std;
using namespace boost;
int main(int argc, char** argv)
{
string text = "token test\tstring";
char_separator<char> sep(" \t");
tokenizer<char_separator<char> > tokens(text, sep);
BOOST_FOREACH(string t, tokens)
{
cout << t << "." << endl;
}
}
打印三个字token
,test
,string
你更新包含路径? –
g ++ -I -c * .cpp –
Arunmu
当你说你将它们复制到“适当的libs文件夹”时,那个文件夹会是什么? – janitor048