How to use Boost in Visual Studio/Qt

To make a long story short, I need to use boost for various reasons.

Anyways, I've searched and searched for an extremely simple way to use Boost in Visual Studio. I'll explain how far I've gotten...

I have downloaded the boost .zip file and extracted it to C:/Program Files/

I understand very little in programming. I'm definitely studying and trying to learn when I have time, so please be patient with me. I just need to be able to use the Boost/Spirit library and I don't know how to get the IDE/compiler or whatever it is to recognize and use the libraries in there.

So if someone could provide a very simple explanation of how to get the project to recognize and use boost libraries, preferably in Qt, I'd highly appreciate it.

Thanks for any help
You first need to compile boost...

Click on start button, locate Visual Studio folder in start menu and select following:
x64 Native tools command prompt

Assuming you have extracted boost zip file into C:\dev example: C:\dev\boost_1_73_0

cd into boost root folder inside command prompt,
Alternatively copy paste following command into developer command prompt:
cd C:\dev\boost_1_73_0
and insert following command to compile x64 debug DLL version of boost:
bootstrap

hit enter and wait to complete, then this command: (update the command as needed)
.\b2 -j 4 --build-dir="C:\dev\boost_1_73_0\build" --stagedir="C:\dev\boost_1_73_0\stage" variant=debug link=shared address-model=64 runtime-link=shared threading=multi toolset=msvc-14.2 --without-graph_parallel --without-mpi


This will take some time approx 5-10 min.

When done you need to configure your project to use boost,
add new project property sheet to your project and following user macro under
Common properties -> User macros -> Add macro (Name/value):
BOOST_ROOT
C:\dev\boost_1_73_0


Next:
Common properties -> C\C++ -> General -> Additional include directories
add following:
$(BOOST_ROOT)

Under Common properties -> C\C++ -> Preprocessor -> preprocessor directives
add following:
BOOST_ALL_DYN_LINK

Setup linker:
Common properties -> Linker -> General -> Additional library directories
insert this:
$(BOOST_ROOT)\stage\lib

That's it, your project is now ready to use boost.

Make sure you save your property sheet somewhere, so that when you create new project you only need to add this existing property to project with no additional configuration needed.

Next time when you compile new version of boost you only need to update BOOST_ROOT user macro in your property sheet.
Last edited on
Imho it clearly suggest OP want Boost t be used directly so must be pre or not compiled header, get statically linked
I see, the spirit library...

Well in that case he can skip compiling and omit BOOST_ALL_DYN_LINK from my instructions, the rest about project settings remains the same.
@malibor

Thank you my good friend. It is highly appreciated and you made that extremely simple and easy to understand. I am quite impressed actually.

good to hear it was easy!

You have detailed info also on boost site:
https://www.boost.org/doc/libs/1_73_0/more/getting_started/windows.html
@malibor thank I really appreciate it and benefit of it..
Topic archived. No new replies allowed.