0

I recently made the switch from a PC to a Mac, Visual Studio to Netbeans, and Java to C++. I tried to include a boost library into my program, and when I build my code, I receive a build error. Can someone please walk me through what this build error is saying? I followed this post to add the libraries. I also followed this Boost getting start tutorial, and the Boost folder is in the "Netbeans Projects" folder, this is the directory "/Users/Nate/NetBeansProjects/boost_1_60_0/boost". Should the boost files have been placed somewhere else?

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

I am trying to build an program that will download website HTML and parse the HTML to retrieve stock prices from fiance.yahoo.com, here is the unfinished code:

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;
}
Community
  • 1
  • 1
Nate
  • 9
  • 1
  • IIRC there isn't a single `libboost.a` stub, but you have to specify them separately as per usage and dependency: `-lboost_asio -lboost_system` – πάντα ῥεῖ Mar 02 '16 at 17:49

1 Answers1

0

As you can clearly see in the error message that "Boost" library not found.

ld: library not found for -lboost

So you need to install it using the following command;

sudo apt-get install libboost-all-dev

Hope this helps.

Edit: As MAC does not support apt-get so you need to use http://brew.sh/. Please have a look in this url http://stackoverflow.com/questions/19688424/why-is-apt-get-function-not-working-in-terminal-on-mac-osx-10-9 for more details about how Homebrew.

Sudipta Kumar Sahoo
  • 1,049
  • 8
  • 16
  • Thanks, but sudo apt-get install libboost-all-dev is not a recognized command in terminal. I am using Mac OSX Snow Leopard, do you know a way around this? – Nate Mar 02 '16 at 18:15