Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link to dynamic boost libs?

Tags:

c++

boost

I compiled boost lib and got these.

//Shared/dynamic link libraries  24/03/2010  11:25 PM            53,248 boost_thread-vc80-mt-1_42.dll 24/03/2010  11:25 PM            17,054 boost_thread-vc80-mt-1_42.lib 24/03/2010  11:25 PM            17,054 boost_thread-vc80-mt.lib  24/03/2010  11:25 PM            73,728 boost_thread-vc80-mt-gd-1_42.dll 24/03/2010  11:25 PM            17,214 boost_thread-vc80-mt-gd-1_42.lib 24/03/2010  11:25 PM            17,214 boost_thread-vc80-mt-gd.lib  // Static libs... does not need any dlls  24/03/2010  11:25 PM           381,716 libboost_thread-vc80-mt-1_42.lib 24/03/2010  11:25 PM           381,716 libboost_thread-vc80-mt.lib  24/03/2010  11:25 PM           999,552 libboost_thread-vc80-mt-gd-1_42.lib 24/03/2010  11:25 PM           999,552 libboost_thread-vc80-mt-gd.lib  24/03/2010  11:25 PM           421,050 libboost_thread-vc80-mt-s-1_42.lib 24/03/2010  11:25 PM           421,050 libboost_thread-vc80-mt-s.lib  24/03/2010  11:25 PM         1,015,688 libboost_thread-vc80-mt-sgd-1_42.lib 24/03/2010  11:25 PM         1,015,688 libboost_thread-vc80-mt-sgd.lib 

In Visual Studio, I have written a test app using the boost thread library. Based on code generation settings it asks for these four libs only (like multithreading debug, multithreading, multithreading debug dll, and multithreading dll)

24/03/2010  11:25 PM           381,716 libboost_thread-vc80-mt-1_42.lib 24/03/2010  11:25 PM           381,716 libboost_thread-vc80-mt.lib  24/03/2010  11:25 PM           999,552 libboost_thread-vc80-mt-gd-1_42.lib 24/03/2010  11:25 PM           999,552 libboost_thread-vc80-mt-gd.lib  24/03/2010  11:25 PM           421,050 libboost_thread-vc80-mt-s-1_42.lib 24/03/2010  11:25 PM           421,050 libboost_thread-vc80-mt-s.lib  24/03/2010  11:25 PM         1,015,688 libboost_thread-vc80-mt-sgd-1_42.lib 24/03/2010  11:25 PM         1,015,688 libboost_thread-vc80-mt-sgd.lib 

Now my question is how can I link my app to the other 2 libs so that it uses the dlls?

24/03/2010  11:25 PM            53,248 boost_thread-vc80-mt-1_42.dll 24/03/2010  11:25 PM            17,054 boost_thread-vc80-mt-1_42.lib 24/03/2010  11:25 PM            17,054 boost_thread-vc80-mt.lib  24/03/2010  11:25 PM            73,728 boost_thread-vc80-mt-gd-1_42.dll 24/03/2010  11:25 PM            17,214 boost_thread-vc80-mt-gd-1_42.lib 24/03/2010  11:25 PM            17,214 boost_thread-vc80-mt-gd.lib 

Question 2. What does the g, s stands for?

like image 260
testingmysql Avatar asked Mar 25 '10 23:03

testingmysql


People also ask

Is Boost dynamically linked?

When the users runtime is dynamically linked the Boost libraries can be built either as dynamic libraries (. so's on Unix platforms, . dll's on Windows) or as static libraries (. a's on Unix, .

How do I link my Boost library to Windows?

Right-click example in the Solution Explorer pane and select Properties from the resulting pop-up menu. In Configuration Properties > Linker > Additional Library Directories, enter the path to the Boost binaries, e.g. C:\Program Files\boost\boost_1_55_0\lib\. From the Build menu, select Build Solution.

How do I add Boost lib?

In the properties dialog, select "Configuration Properties" and then "VC++ Directories". You will need to add the Boost include path to the "Include Directories" list. If you're using all header-only libraries then you're done. Otherwise, you will need to add the Boost library path to "Library Directories".

What is Dynamic Link in C++?

In dynamic linking, the library object code is linked to the executable binary at runtime. So, now we have a runtime dependency on the library file. If that shared object ( . so file) is not discoverable at runtime, the executable binary won't run.


1 Answers

You can force Boost to use the DLLs by defining BOOST_ALL_DYN_LINK - either in your C++ preprocessor settings or by a #define in your stdafx.h pre-compiled header, e.g.:

#define BOOST_ALL_DYN_LINK

like image 99
Rob Avatar answered Sep 28 '22 02:09

Rob