Как сделать ссылку на динамический буст-библиотеки? - PullRequest
29 голосов
/ 26 марта 2010

Я скомпилировал boost lib и получил их.

//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

В Visual Studio я написал тестовое приложение с использованием библиотеки потоков потоков. Основываясь на настройках генерации кода, он запрашивает только эти четыре библиотеки (например, отладка многопоточности, многопоточность отладки DLL и многопоточности 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

Теперь мой вопрос: как мне связать мое приложение с двумя другими библиотеками, чтобы оно использовало библиотеки DLL?

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

Вопрос 2. Что означает g, s?

Ответы [ 3 ]

33 голосов
/ 26 марта 2010

Вы можете заставить Boost использовать библиотеки DLL, определив BOOST_ALL_DYN_LINK - либо в настройках препроцессора C ++, либо #define в предварительно скомпилированном заголовке stdafx.h, например:

.

#define BOOST_ALL_DYN_LINK

20 голосов
/ 16 июня 2010

Для настройки boost используйте заголовок пользовательской конфигурации

<boost/config/user.hpp>

Тогда просто найдите динамические линии связи и измените желаемую конфигурацию

// BOOST_ALL_DYN_LINK: Forces all libraries that have separate source, 
// to be linked as DLL's rather than static libraries on Microsoft Windows 
// (this macro is used to turn on __declspec(dllimport) modifiers, so that 
// the compiler knows which symbols to look for in a DLL rather than in a 
// static library).  Note that there may be some libraries that can only 
// be statically linked (Boost.Test for example) and others which may only 
// be dynamically linked (Boost.Threads for example), in these cases this 
// macro has no effect.
// #define BOOST_ALL_DYN_LINK
11 голосов
/ 26 марта 2010
  1. Файлы .lib связаны статически, а файлы .dll - динамически. Я считаю, что это настройка проекта VC.

The "lib" prefix is for static libraries. Use link=static 
The 's' letter is to static linking to runtime. Use runtime-link=static 
The 'd' is debug, use variant=debug 
The 'g' is using debug runtime, I think it's included in 'debug' variant 
already. If not runtime-debugging=on will help. 

Источник: http://old.nabble.com/Build-statically-linked-boost-libs-*-vc90-mt-sgd.lib-td16301103.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...