How do I include Boost libraries?

I am trying to include Boost libraries in my program, specifically lexical_cast

and geometry

. I include them using #include"boost/boost/geometry.hpp"

and #include"boost/boost/lexical_cast/lexical_cast_old.hpp"

.

When I run the code, I get the fatal error "Cannot open include file: 'boost / geometry / geometry.hpp': no ​​such file or directory", which leads me to another .hpp file in the Boost library that includes another library but uses #include<...>

instead #include"..."

.

When I replace it with "..."

an error appears for this, but it is replaced by the following library included using #include<...>

instead #include"..."

.

I feel like this could lead me to a rabbit hole, replacing almost all of the copies #include<...>

with #include"..."

which will take a long time. Is there a setting that I can change, or a piece of code I could include to figure this out?

Or I could just get rid of all the other unnecessary libraries and change the ones that I need (I know this will still be a lot as they seem to rely on each other).

I have Boost library version 1.58.0.

+5


source to share


3 answers


You should first read about the difference between #include "filepath"

and #include <filepath>

here .

Personally, I work with Boost from Visual Studio like this:



  1. Go to Project Properties -> C / C ++ -> General -> Additional Include Directories and add the path to the library root directory boost

    (in my case C:\Program Files (x86)\Boost_1_53

    ).
  2. Include the .hpp file in your sources like #include <boost/lexical_cast/lexical_cast_old.hpp>

If you are using libraries for more than just headers, you must also add the Boost Libraries path to Project Properties -> Linker -> General -> Additional Library Directories.

+7


source


For example:



  1. Boost Library - c:\boost\boost_1_58_0

    (start booststrap.bat

    and b2

    administrator).
  2. Add lines $(THIRD_PARTY)\boost\boost_1_58_0\include

    and $(THIRD_PARTY)\boost\boost_1_58_0\

    in VC ++ directories -> Include directories
0


source


In Visual Studio 2012, right click on your project and select Properties.

In the Properties dialog box, select Configuration Properties and then VC ++ Directories.

You will need to add the Boost include path to the Include Directories list.

If you use all libraries for headers only, then you're done. Otherwise, you will need to add the Boost library path to Catalog Libraries.

0


source







All Articles