【发布时间】:2016-11-26 21:54:03
【问题描述】:
我正在尝试在我的 C++ 应用程序中使用 boost 库。我正在尝试使用具有不同选项的 g++ 编译它。例如 g++ -I /usr/include/boost/filesystem/ -o test.out test.cpp 但它总是提示 error: 'boost' has not been declared。
这是我的代码:
#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;
}
如果你能帮我解决这个问题,我会很高兴。
附:我正在 Centos 4.7 中编译我的应用程序,它包含根据 /usr/include/boost/version.hpp 的 Boost 1.32 版
更新:
我也评论了 boost 指令,但包含有一些问题:boost/filesystem.hpp: No such file or directory。
【问题讨论】:
-
@drescherjm 已更新。感谢您的通知。