【问题标题】:Build Fail- Error Message Translatopn构建失败 - 错误消息翻译
【发布时间】:2016-06-15 17:36:04
【问题描述】:

我最近从 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;
}

【问题讨论】:

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

标签: c++ boost netbeans cygwin


【解决方案1】:

您可以在错误消息中清楚地看到“Boost”库未找到。

ld: library not found for -lboost

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

sudo apt-get install libboost-all-dev

希望这会有所帮助。

编辑: 由于 MAC 不支持apt-get,所以你需要使用http://brew.sh/。 请查看此网址 http://stackoverflow.com/questions/19688424/why-is-apt-get-function-not-working-in-terminal-on-mac-osx-10-9 以了解有关 Homebrew 的更多详细信息。

【讨论】:

  • 谢谢,但 sudo apt-get install libboost-all-dev 不是终端中可识别的命令。我正在使用 Mac OSX Snow Leopard,你知道解决方法吗?
猜你喜欢
  • 1970-01-01
  • 2014-04-30
  • 1970-01-01
  • 2013-01-15
  • 1970-01-01
  • 1970-01-01
  • 2012-11-26
  • 2015-11-05
  • 1970-01-01
相关资源
最近更新 更多