Boost lib appears to be missing hpp files?

You should make sure that your include path is set correctly. Assuming you downloaded Boost 1.47.0 your path should contain the location to your Boost installation up to the boost_1_47_0 directory, but leaving out the boost one, e.g.

/path/to/boost/boost_1_47_0

and not

/path/to/boost/boost_1_47_0/boost

On Fedora and Centos yum install -y boost and yum install -y boost-devel


I got this error on Ubuntu 12.10 when trying to use boost with a C++ application without the libraries installed:

el@apollo:~/foo8/33_parse_file$ g++ -o s s.cpp
s.cpp:3:29: fatal error: boost/foreach.hpp: No such file or directory
compilation terminated.

From this code:

#include <iostream>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
using namespace std;
int main(){
  cout << "hi";
}

I'm on Ubuntu 12.10 so I installed Boost like this:

sudo apt-get install libboost-all-dev

Then on recompile, it works and now I can use boost!

#include <iostream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>

using namespace std;
using namespace boost;

int main(int argc, char** argv)
{
    string text = "token  test\tstring";

    char_separator<char> sep(" \t");
    tokenizer<char_separator<char> > tokens(text, sep);
    BOOST_FOREACH(string t, tokens)
    {
        cout << t << "." << endl;
    }
}

Prints the three words token, test, string

Tags:

C++

Boost

Mingw