我想在我的C++应用程序中使用boost库。我试图使用不同的选项使用g ++编译它,例如g++ -I /usr/include/boost/filesystem/ -o test.out test.cpp
但是它总是提示error: 'boost' has not been declared
。错误:'boost'还没有被声明
这里是我的代码:
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
using namespace std;
int main(){
string line;
string fileName = "Read.txt";
ifstream file;
string str;
file.open(fileName.c_str());
cout << "Hello, world!\n";
vector<string> fileLines;
fileLines.clear();
while (getline(file, str))
{
fileLines.push_back(line);
}
cout << "Total Line count:"<<fileLines.size()<<endl;
fileLines.clear();
cout << "Total Line count:"<<fileLines.size()<<endl;
boost::filesystem::path p("/tmp/foo.txt");
return 0;
}
我会很高兴,如果你帮我解决这个问题。
P.S.我编译我的应用程序在Centos的4.7,它包含根据/usr/include/boost/version.hpp
更新升压版本1.32:
我还评论提振指令,但有一些问题,包括:boost/filesystem.hpp: No such file or directory
。
@drescherjm更新。感谢您的通知。 – VSB