Building boost with ICU support on Linux - c++

boost build produces libboost-locale and libboost-regex so-files (elf) with RUNPATH=absolute/path/to/icu/build/bin
But I need to make my app portable with both boost and ICU so-files to be in the lib sub-directory inside my app distribution.
I am building boost with following commands:
./bootstrap.sh --prefix=absolute/path/to/myapp/build --with-icu=absolute/path/to/icu/build
./b2 install --with-locale --with-regex link=static,shared runtime-link=shared address-model=64 -sICU_PATH=absolute/path/to/icu/build
So it makes RUNPATHs=absolute/path/to/icu/build/bin (so also adds 'bin' to the passed ICU path).
When I add hardcode-dll-paths=true dll-path=".:../lib" to b2 command, it supplements RUNPATHs with ".:../lib", but absolute path to ICU-build is still there.

Related

how to install boost correctly

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:
extract boost_1_61_0 for example to C: so new folder named "C:\boost_1_61_0"
from a command prompt or visual studio 2015-> Visual studio tools-> developer command prompt for ms2015 (run it as administrator)
cd C:\boost_1_61_0
bootstrap.bat
So new files are created: b2.exe and bjam.exe in the root folder. Now we build the x64 version of boost library:
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
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
wait until it's done.
now we have the two versions x64 and win32 but the root folder is too much big about 5.3 gigabyte.
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
I add install and changes the name of folder from stage to "C:\Boost\X64"
when it's done a new folder "C:\Boost" is created it contains include folder and x64 folder which contains lib files.
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
when it's done remove a folder named lib inside: C:\Boost\
time to clean and free up memory:
remove the hole folder: C:\Boost_1_61_0 because we don't need it again
** 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.

Can Boost Log be built as a .dll/.so in a static Boost build?

Is it possible to build Boost Log as a dynamic library (.dll/.so), but do so within a static Boost build? I'd like all the other Boost libraries to be static, and only Boost Log as a .dll (because several .dlls use it within the same application).
Do all the Boost libraries need to be dynamic to get a Boost Log .dll? I've tried to add define=BOOST_LOG_DYN_LINK to my bjam command line, to no avail:
bjam --toolset=msvc-10.0 address-model=64 variant=release,debug link=static threading=multi runtime-link=static define=BOOST_LOG_DYN_LINK
You can narrow the scope of the build by specifying only the library you want to build using the --with-<library> switch, eg.,
./bjam link=shared --with-log ...

How to build boost required modules only?

I just started compiling boost C++ libraries. With the following commands I issued it is building whole of the boost libraries, which is time consuming, and is not necessary for my need.
Just unpacked the boost_1_49_0.7z archive and from Visual Studio 2010 command line tool I ran bootstrap.bat and it created the b2 executable.
Using this executable I ran b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage to build the libraries.
At this moment all I need is the "signals" module to be built.
What switch commands need to be supplied to the bootstrap created executable to compile and build only those specific libraries?
b2.exe --help outputs the following.
--show-libraries Displays the list of Boost libraries that require
build and installation steps, then exit.
--with-<library> Build and install the specified <library>
If this option is used, only libraries
specified using this option will be built.
Also is possible to use the -jX option to compile BOOST in X processes in parallel.

How to build boost static libs?

This works, but doesn't build static versions of boost libraries (maybe i am wrong?)
bjam --toolset=gcc --prefix=C:\boost_1_49_0-mingw install
Trying to issue folloving command:
bjam --toolset=gcc --prefix=C:\boost_1_49_0-mingw --build-type=complete install
but it doesn't work.
You should be able to use the link=static option to let you compile the library into your binary without needing the dynamic lib:
sudo ./b2 link=static
Check your stage directory to make sure it goes in the right spot and then re-install to whatever system directory you include.

Building Boost for static linking (MinGW)

I'm building Boost (I'm using System and FileSystem) for MinGW using bjam:
bjam --toolset=gcc stage
And it builds fine, but I want to be able to statically link to it (I have to have a single file for the final product) so I tried:
bjam --link=static --toolset=gcc stage
But I get the same output. Any ideas?
edit second question in a row I've answered moments after posting :p guess I'll leave this up here for others though.
bjam --build-type=complete --toolset=gcc stage
Will build both dynamic and static for sure.
I think link is a property as opposed to an option for bjam. That means that there should be no -- before it.
This is my command line for building only static libraries (visual c++ though):
bjam install --toolset=msvc variant=release link=static threading=multi runtime-link=static
Mapping that to your original build command I would say it should look something like this:
bjam --toolset=gcc link=static stage
or perhaps:
bjam stage --toolset=gcc link=static
Try running
bjam --help
for more info on properties and options for bjam.
Just want note that with the newer boost (Feb 2011) you need to build bjam as well now.. for some reason the current downloadable bjam doesn't work cleanly.
So first:
cd ...\boost_1_45_0\tools\build\v2\engine\src
build.bat mingw
Youll need to add bjam to the PATH (from control panel, not just on the cmd prompt). Then
cd ...\boost_1_45_0\
bjam --build-type=complete --toolset=gcc stage
My setup is Vista, Boost 1.45, MinGW 4.5, and building from cmd.exe not msys.
http://code-slim-jim.blogspot.com/2011/02/boost-in-vista-using-mingw-and-cmdexe.html
I have not built this myself in MinGW but I believe your first build will output both dynamic and static libraries and the second only static ones, so if you did not clean the build directories in between builds it will probably look the same.
When you write "I have to have a single file..." do you mean you need a single library containing all boost libraries? If so, I suspect you may have to 'ar' them together yourself.
I use the following command line to build both the statically linked as well as the dynamically linked versions of boost:
bjam "-sBUILD=debug release <runtime-link>static/dynamic <threading>multi" stage
This is done with visual c++ on windows YMMV.