我想在我的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