3

I really want to get in to using the boost library and I am having trouble "installing" it.

I want to be able to access the functionality by saying

#include <boost/signals2/signal.hpp>

then g++ filename.cpp.

instead of having to write

#include "boost/signals2/signal.hpp"

and have chunks of boost in my local directory.

Is there a way in which I can set up boost such that this works? I have downloaded the boost library and extracted it to /usr/local.

1

2 Answers 2

5

The easiest way to use boost in Fedora is to simply install the boost-devel package, e.g.:

sudo dnf install boost-devel

It will install the boost include files in /usr/include and the boost library files in /usr/lib64.
I.e. the default include and library paths for gcc on Fedora, so gccwon't need the -I and -L options.

The installed version of boostdepends on your version of Fedora, see RPM resource boost-devel.

Sign up to request clarification or add additional context in comments.

2 Comments

I did this, now g++ filename.cpp throws a TON of undefined references. When installing boost this way what exactly do I type in the command line? g++ -lboost filename.cpp doesnt work either, cannot find -lboost
You need to add -l arguments to gcc for the missing boost libraries. It's not as simple as just -lboost. You can ls /usr/lib64 to see which libboost files were installed.
1

This is because you are not passing the include directory to g++. Your compiler command should be:

g++ filename.cpp -I /path/to/boost/headers

Sometimes it may happen that a few headers are not found. Then you must include multiple directories where you may find all the headers. To include multiple directories see this answer.

Don't forget to link the corresponding library as well! You can see this answer on how to do it.

Another solution would be to install boost with brew or a package manager at the default location which is included in C_INCLUDE_PATH such as /usr/local. However, if you intend to work with OR have multiple versions of boost, you quickly run into problems.

2 Comments

boost.org/doc/libs/1_48_0/libs/locale/doc/html/… This file with g++ -I/usr/local/boost/include -L/usr/local/boost/libs -lboost myfirstboost.cpp throws boost/locale.hpp: No such file or directory #include <boost/locale.hpp>
Its probably because, boost can't find that header and then you have to include several directories and link several libraries. See edit to answer.