How to use boost in linux

I am trying to use a generic pointer class (?) From boost. I have a reduced gain and extracting it to a subfolder (boost) in my source folder (src). Then I added the line:

#include "boost/shared_ptr.hpp" 

When I try to compile, I get an error message:

error: boost / smart_ptr / shared_ptr.hpp: no such file or directory

What do I need to add to compile the program?

I am working on a Linux scientific machine without root privileges

+4
source share
3 answers

You will need to add g++ with g++ as a compilation parameter, for example g++ -I./boost ... , or simply add -I as a command line option, followed immediately by a space, in the relative or absolute path where you set your acceleration library. Keep in mind also for future reference that some boost elements, such as a streaming library, also require some libraries to be associated with them, and you will also have to include these file paths at compile time using the -L option ... that this does not apply to boost::shared_ptr , but just gives you a head up.

+11
source

Assuming you have installed boost in some subdirectory of your home directory, you will need to do one of them to indicate where the compiler should look for boost header files:

  • add -I flag to compiler command line ( GCC docs )
  • set the environment variable CPLUS_INCLUDE_PATH ( GCC docs )
+5
source

You can add the gcc -I option. Documentation

+2
source

All Articles