3

I'm using Raspberry Pi 3B+. I'm trying to compile a rather massive C++ package given to me from somewhere else. However make fails compiling. It cannot find boost/asio.hpp. I simplified the problem into this minimal version. This is my helloboost.c

#include <memory>
#include <string>
#include <vector>
#include <utility>
#include <boost/asio.hpp>

int main() {
  printf("hello boost\n");
  return(0);
}

If I comment out the #include <boost/asio.hpp> line it compiles with g++ helloboost.c just fine and works, but with this version the following error appears:

pi@raspberrypi:~/Documents/tmp_tests $ g++ helloboost.c 
helloboost.c:5:26: fatal error: boost/asio.hpp: No such file or directory
 #include <boost/asio.hpp>
                          ^
compilation terminated.

Apparently it does find the other include files. Here is a similar question but it has not been answered. A comment there suggests making it a "SSCCE", I don't know what that means. Any help is appreciated.

user9393931
  • 53
  • 1
  • 5

2 Answers2

2

You have to install the headers for the boost libraries.

For most libraries, there are the runtime packages and the development packages. The runtime packages are needed to execute the programs and for development, the development packages are needed only for development. Usually the development packages have a -devel or -dev suffix.

For the boost library, install libboost-dev.

RalfFriedl
  • 2,188
  • 2
  • 10
  • 11
  • 1
    Further on this, later I hit another bug: I was missing boost_thread, boost_chrono etc. The solution was to install libboost-all-dev as in this: [https://raspberrypi.stackexchange.com/a/60349/103870] – user9393931 Jun 27 '19 at 11:59
1

Another alternative that I have used is to install the standalone non-boost version via

apt-get install libasio-dev

The last I checked there was still a somewhat inadvertent dependency on one of the boost libraries anyway, but perhaps that has been resolved by now or it may be that the portions of asio that you need are unaffected. I found this to be a useful approach since many of the features of boost have already found their way into the C++ standard and into gcc.

Edward
  • 961
  • 1
  • 6
  • 24