1
votes

I'm trying to compile a full independent static executable file with MS Visual C++ - Express.

I'm use the boost libraries, which are also compiled with static linking:

b2 --toolset=msvc-10.0 --link=static runtime-link=static variant=release threading=multi

In Visual Studio I have these settings:

General: MFC use static library

VC++ Directories -> Include Directory: PATH TO BOOST FILES

C/C++ -> Code Generation: Runtime Library Muthithreaded

C/C++ -> Precompiled Header: Don't use

Linker-> Input: Additional dependencies: FULL PATH TO ALL USED BOOST LIB FILES (C:\boost_1_61_0\stage\lib\libboost_system-vc100-mt-gd-1_61.lib....)

I can compile a dynamicly linked executable, but if I try a static executable I receive this error:

1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-sgd-1_61.lib'

Where is the problem?

1

1 Answers

1
votes

Properties should not be prefixed with --, so your build command should look something like:

b2 toolset=msvc-10.0 link=static runtime-link=static variant=release threading=multi

Additionally, you seem to be building your project in debug mode, so the linker is looking for the debug versions of the boost libs. It would probably be a good idea to build both the debug and release versions, so that you can build your project in both debug and release mode:

b2 toolset=msvc-10.0 link=static runtime-link=static variant=debug,release threading=multi

That will generate two versions of each library, 'libboost_foo-vc100-mt-s-1_61.lib' and 'libboost_foo-vc100-mt-sgd-1_61.lib'. The 's' version is the release lib, and the 'sgd' version is the debug lib. See the boost docs for exactly what each of those characters means.


EDIT: After looking at your setup again, it looks like you've manually specified the path to all of the boost libs that you're using. In addition to what I mentioned above about build properties, you should specify the library search path under VC++ Directories -> Library Directories. In Visual Studio, boost will specify which libraries it needs using #pragma comment(lib, ...) preprocessor directives. You can disable this behavior for a single library by defining BOOST_<lib>_NO_LIB before including its header, or for all libraries by defining BOOST_ALL_NO_LIB.