【发布时间】: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