Building Boost for static linking (MinGW)
Asked Answered
C

4

29

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.

Cubiform answered 30/1, 2009 at 6:12 Comment(0)
B
41

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.

Borreri answered 30/1, 2009 at 12:48 Comment(0)
A
9

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

Armijo answered 16/2, 2011 at 15:6 Comment(1)
Thanks! The missing bjam was a surprise to me when updating my boost version recently.Marchpane
K
0

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.

Kemeny answered 30/1, 2009 at 6:21 Comment(1)
thanks for the reply, what I meant by "I have to have a single file..." is that I must have my executable, and no DLLs shipped with it.Cubiform
E
0

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.

Exist answered 30/1, 2009 at 12:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.