Boost linker Multi-threaded build issue - boost

I've been using a successfully built boost library version 1.55.0 for a few weeks now but I ran into error LNK1140 cannot open file 'libboost_filesystem-vc120-mt-sgd-1_55.lib when I try using Multi-threaded(/MT) rather than /MD. I've been searching through forums and it seems that I need to statically link the library so I tried running .\b2 --with-thread variant=release link=static threading=multi runtime-link=static but that didn't work either. I have C:/Boost/1.55.0/VC/12.0 in VC++ Directories->Include Directories and C:\Boost\1.55.0\VC\12.0\stage\lib in Linker->General->Additional Library Directories. Any ideas?

Related

boost 1.66.0 with visual studio 2017, b2 keeps using cl.exe under ARM folder

I scratched my head hard but could not find someone asks the same question.
I'm building boost 1.66 with VS2017 on my machine, the command I'm using is b2 -a -j6 toolset=msvc-14.1 link=static runtime-link=static,shared address-model=64 architecture=x86 define=BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE --with-math.
I think it should use cl.exe from Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\<version>\bin\Hostx64\x64
However, from the log b2 gives me
It looks really weird to me that it's using cl.exe under arm folder to compile my address-model=64 binaries. My question is, will the binary be the same as what I expected? Could this be a bug in boost build engine, and is there a workaround to make this look right?
P.S.: I've tried editing project-config.jam to hardcode the path of desired location of compiler, but it returns me "could not locate correct compiler cl". What I referenced is: build-boost-with-msvc-14-1-vs2017-rc

Statically link Boost Thread 1.56 lib in an Xcode 6 project

I have a very simple Xcode 6 project in which I'm trying to link to boost_thread and boost_system statically. I've build the libraries (I have the libboost_thread.a and libboost_system.a), I've included all the right header/library search paths, flags etc as I do with any other static lib in the project and the project builds successfully, yet when I run it, it gives me a runtime dlopen error that it can't find the boost_thread.dylib lib ?!
I do not link to any dylib version of any boost lib, only those two static ones. Why is it trying to dynamically load a library? Can anyone give me a hint on what's this all about?
Thanks
The quick fix:
Clean out boost and run bjam again with link=static
The explanation for anyone that stumbles on this, here's what the problem was:
I had build the entire boost package with its default config. That, however, for whatever reason does not include the static libs for system and thread. Running bjam after that sith link=static did infact build the libs but for whatever reason, they were pointing to the dylibs...

How compile a DLL which is using boost library?

I'm working on a DLL project in VS 2010, I want to use boost mutex in some part of my code. but when I compile project to release final DLL, I get this linkage error:
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc100-mt-1_49.lib'
I've already compiled boost with this command:
bjam install --toolset=msvc variant=release link=static threading=multi runtime-link=static
& I've a file named libboost_date_time-vc100-mt-s-1_49.lib, when I change configuration type of my project from Dynamic Linked Library (DLL) to Static Library, the project builds successfully, but I need to release only as a DLL file (& my final DLL CAN NOT have any dependency to other external DLLs). I know the problem causes by compilation of boost, but I don't know how should I recompile it
Any guideline?
Check that you link the runtime-library statically (Configuration properties-->C/C++-->Code generation-->Runtime library: Multi-threaded (/MT).
Otherwise, link CRT and boost dynamically. For this purpose build boost like this:
bjam --toolset=msvc variant=release link=shared threading=multi runtime-link=shared
IMO, you built the boost library just fine : you used link=static which means you would like to emit static library (and not a DLL) and since you would like to have standalone deployment , you specified runtime-link=static meaning you link against MS C/C++ run time as static libraries (e.g. the code for printf() will be embedded in your final library and not be referenced to msvcr100.dll)
Please take a look at the picture below, make sure to set the full path of the directory where your boost library resides under Additional Library Dependencies
I fixed my error "Error LNK1104 cannot open file 'libboost_locale-vc142-mt-gd-x32-1_73.lib'" in a DLL project, which I described in this issue on boost' github by installing the boost library using vcpkg.
Install vcpkg. Then write .\vcpkg install boost. You can see how it's done in the video: https://youtu.be/b7SdgK7Y510 . He's not installing the boost library but the process is exactly the same.
This is all for Windows and Visual Studio's toolset, of course.

Building Boost Libs

About 3 months ago I managed to build boost libs and left myself the following instructions:
Extract boost to ->
cd C:\Program Files\boost\boost_1_43_0
Build bjam ->
bootstrap.bat
Issue the following command ->
bjam --toolset=msvc-9.0 stage variant=debug threading=multi link=static runtime-link=static --with-filesystem --with-iostreams --with-regex --with-serialization --with-signals --with-system --with-thread --with-wave
before it build the libs in the default 'stage' directory. Now the command fails to accept any of the lib names. If i remove filesystem, it fails on the next... and so on.
C:\Program Files\boost\boost_1_44_0>win32_build_boost_libs.bat
error: wrong library name 'filesystem' in the --with- option.
Can anyone tell me why I've spent 3 hours trying to google for this but can't find anything :-(
I'm sure its something stupid but the process works on my old laptop but not on my new. They both have the same visual studio, version of boost, archive of boost, path variables... It really is quite frustrating.
You can use BlueGo to build boost - it supports different boost and Visual Studio versions: https://bitbucket.org/Vertexwahn/bluego

compile Boost as static Universal binary lib

I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.)
I found many Google hits with similar problems and possible solutions. However, most of them seems outdated. Also none of them really worked.
Right now, I am trying
sudo ./bjam --toolset=darwin --link=static --threading=multi \
--architecture=combined --address-model=32_64 \
--macosx-version=10.4 --macosx-version-min=10.4 \
install
That compiles and install fine. However, the produced binaries seems broken.
az#ip245 47 (openlierox) %file /usr/local/lib/libboost_signals.a
/usr/local/lib/libboost_signals.a: current ar archive random library
az#ip245 49 (openlierox) %lipo -info /usr/local/lib/libboost_signals.a
input file /usr/local/lib/libboost_signals.a is not a fat file
Non-fat file: /usr/local/lib/libboost_signals.a is architecture: x86_64
Edit: It seems that the command was wrong and I must remove the "--" for most options. So the command I am trying now (-a just means to rebuild all):
sudo ./bjam -a toolset=darwin link=static threading=multi \
architecture=combined address-model=32_64 \
macosx-version=10.4 macosx-version-min=10.4 \
install
However, this gives many strange errors (what I already had earlier), all like this:
darwin.compile.c++.pch bin.v2/libs/math/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/macosx-version-min-10.4/macosx-version-10.4/threading-multi/../src/tr1/pch.hpp.gch
In file included from ./boost/math/special_functions/acosh.hpp:18,
from ./boost/math/special_functions.hpp:15,
from libs/math/build/../src/tr1/pch.hpp:9:
./boost/config/no_tr1/cmath.hpp:21:19: error: cmath: No such file or directory
This could be another problem I have when building Universal binaries: g++ on MacOSX doesn't work with -arch ppc64
I found the problem. It seems that the MacOSX 10.4 SDK is missing a bunch of symlinks for GCC 4.2.
Use this as a test case:
g++ on MacOSX doesn't work with -arch ppc64
It will report multiple errors with GCC 4.2 (missing C++ includes, missing C includes, missing libs). In all cases, you can just fix that by setting a symlink. Search in your SDK for the file and just set the symlink in the same way it is in the MacOSX 10.5 SDK.
After that, it all just worked.
We use Boost compiled for 10.4 here at work. We don't use GCC 4.2 on it though, rather we use GCC 4.0 as Apple's GCC 4.2 is not supported for the MacOS 10.4 SDK. To accomplish this you need a bjam user config file, eg. user-config-darwin.jam. Here's the contents of ours. Modify to your heart's content:
# Boost.Build Configuration
# Compiler configuration
using darwin : 8.11 : /usr/bin/g++-4.0 :
<architecture>"combined"
<address-model>"32" # this can be changed to 32_64 for 32/64 universal builds
<macosx-version>"10.4"
<macosx-version-min>"10.4"
# <root>"/Developer"
<compileflags>""
<linkflags>"" ;
Then, you need to tell bjam to use the user config jam file when compiling:
bjam --user-config=user-config-darwin.jam ... (your other options go here) ...
Now you don't have to mess with symlinks in the system SDK directories.
To build 4-way universal boost static binaries on OSX 10.6 I do the following:
Download boost from the boost website.
Extract the archive and cd into the boost_1_xx_0 folder (where xx is the version of boost you are using).
Run:
./bootstrap.sh and then
./bjam macosx-version=10.6 macosx-version-min=10.4 architecture=combined threading=multi link=static address-model=32_64
This will compile everything except for Boost.MPI (which requires the --with-mpi option). The build products get put in ./stage

Resources