构建失败错误消息Translatopn

问题描述:

我最近从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”。 boost文件应该放在别的地方吗?构建失败错误消息Translatopn

"/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

IIRC没有一个'libboost.a'存根,但必须根据用法和依赖性分别指定它们:'-lboost_asio -lboost_system' –

,你可以在错误消息中清楚地看到没有找到“Boost”库。

ld: library not found for -lboost 

所以你需要使用下面的命令安装它;

sudo apt-get install libboost-all-dev 

希望这会有所帮助。因为MAC不支持apt-get所以你需要使用http://brew.sh/。 请查看此网址http://*.com/questions/19688424/why-is-apt-get-function-not-working-in-terminal-on-mac-osx-10-9以了解有关Homebrew的更多详细信息。

+0

谢谢,但sudo apt-get install libboost-all-dev在终端中不是公认的命令。我使用的是Mac OSX Snow Leopard,你知道解决这个问题的方法吗? – Nate

+0

@Nate我编辑了答案,请看看。 –