我最近从PC切换到Mac,从Visual Studio切换到Netbeans,从Java切换到C ++。我试图在我的程序中包含一个boost库,当我构建我的代码时,我收到一个构建错误。有人可以告诉我这个构建错误说的是什么吗?我跟着this post to add the libraries。我也跟着this Boost getting start tutorial,Boost文件夹位于“Netbeans Projects”文件夹中,这是“/Users/Nate/NetBeansProjects/boost_1_60_0/boost
”目录。升压文件是否应放在其他地方?
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/stockapp
mkdir -p dist/Debug/GNU-MacOSX
g++ -o dist/Debug/GNU-MacOSX/stockapp build/Debug/GNU-MacOSX/main.o -L../boost_1_60_0/boost -l boost
ld: library not found for -lboost
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-MacOSX/stockapp] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 213ms)
我正在尝试构建一个程序,它将下载网站HTML并解析HTML以从fiance.yahoo.com检索股票价格,这是未完成的代码:
using namespace std;
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <boost/asio.hpp> //code worked before adding this include
static string Index; //initialize string hosting Index Name
static vector<string> Symbol;
int ReadIndexFile()
{
string FileRead;
string FileName;
//string Temp;
int count = 0;
FileName = Index + "Symbols.csv";
cout << FileName << "\n";
ifstream source(FileName.c_str());//establishes source file
while (!source.eof()) //reads source until end of file
{
while (getline(source, FileRead, ','))//retrieves source data to ',' and stores in temp
{
Symbol.push_back(FileRead); //writes to array line by line
cout << Symbol.at(count);
count++;
}
}
}
int DownloadHTML()
{
cout << "HTML Downloaded";
}
int main(int argc, char** argv) {
cout << "Name your Index: ";
cin >> Index;
ReadIndexFile();
DownloadHTML();
return 0;
}
答案 0 :(得分:0)
正如您可以在错误消息中清楚地看到未找到“Boost”库。
ld: library not found for -lboost
所以你需要使用以下命令安装它;
sudo apt-get install libboost-all-dev
希望这有帮助。
编辑:
由于MAC不支持apt-get
,因此您需要使用http://brew.sh/。
有关Homebrew
的详细信息,请查看此网址http://stackoverflow.com/questions/19688424/why-is-apt-get-function-not-working-in-terminal-on-mac-osx-10-9。