I've downloaded boost_1_61_0
and unzipped it. I used bootstrap.bat
generating b2.exe
and bjam.exe
and successfully built libraries in a folder named "stage" for both x64
and win32
.
After I have .lib
and boost
folders containing include files.
When I remove the root folder I can't build my program. Why am I unable to build the code?
I have used bs as:
b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64 install
It creates C:\\boost
that contains libs and header files. But when I try to use this new folder in my project I get errors: couldn't find eg: boost/reg.hpp
Is there a correct way to install boost after building it?
I figured it out:
So new files are created: b2.exe and bjam.exe in the root folder. Now we build the x64 version of boost library:
new folder "Stage" is created in root folder, inside this folder there's a folder named x64 inside which there's a folder "lib" (.lib files). the process takes some minutes (about 20 minutes)
when it's done a message tells you that boost_1_61_0 skips some targets, don't mind it's nothing because it belongs to other OSs
now we build the x86 version:
b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32
now we install these two libraries to "C:\\Boost" and then clean by removing the folder "C:\\boost_1_61_0":
b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=C:\\Boost\\x64 install
now we install win32 version: b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=C:\\Boost\\win32 install
** how to add boost to my project?:
open Msvc2015->create c++ console new project, when it's created go to Project-> "MyBoostProject's" properties->C/C++->General->Additional include directories->edit->new folder->C:\\Boost\\include->boost_1_61 add another folder with the path: C:\\Boost\\include->Boost_1_61_0->Boost
now the include files are ready.
** How to link?:
If my project is x86: go to: linker->General->Additional Library Directories->edit->Add new folder->C:\\Boost\\win32\\Lib
If my project is x64:
linker->Additional library directories->edit->add new folder->C:\\Boost\\x64\\Lib
I wish this post would be useful for anyone who was not able to install it.
The boost includes are in the folder you created called c:\\boost. So the path is c:\\boost\\boost as it looks you have found out.
But better yet is to use environment variables. You will find them under control panel > system > advanced >...
Set BOOST_ROOT
to c:\\boost and BOOST_LIB
to your stage path. I keep all the builds v100, v140 x86 and 64 bit in the same folder. Then in your projects you can set additional include directories to $(BOOST_ROOT) and lib directories to $(BOOST_LIB)
This gets you lots of advantages like when 6.62 comes out you can put it in c:\\boost_62 and change your environment variables then all your projects are using the new boost. You don't have to get stuck with c:\\boost. And if you share the project with someone else with a different path, it just works.
BOOST_ROOT looks pretty universal out there, I don't know about BOOST_LIB
Also, if you change an environment variable, you will have to close Visual Studio and reopen it to have the change take affect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.