2010-03-25 18 views
26

Compilé boost lib y obtuve estos.¿Cómo vincular a libs de impulso dinámico?

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

En Visual Studio, he escrito una aplicación de prueba utilizando la biblioteca de subprocesos impulso. Sobre la base de la configuración de generación de código que pide sólo estas cuatro bibliotecas (como multi-hilo de depuración, multihilo, multihilo DLL de depuración, y DLL multihilo)

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 

Ahora mi pregunta es cómo puedo vincular mi aplicación a los otros 2 libs por lo que usa los 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 

Pregunta 2. ¿Qué significa g, s?

Respuesta

9
  1. Los archivos .lib están vinculados estáticamente, mientras que los archivos .dll están vinculados dinámicamente. Creo que es una configuración de proyecto de 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. 

Fuente: http://old.nabble.com/Build-statically-linked-boost-libs- * -vc90-mt-sgd.lib-td16301103.html

+6

mejor fuente: http: //www.boost .org/doc/libs/1_42_0/more/getting_started/windows.html # library-naming –

28

Puede fuerza de ayuda para utilizar los archivos DLL mediante la definición de BOOST_ALL_DYN_LINK - ya sea en su Configuración del preprocesador de C++ o por un #define en su encabezado precompilado stdafx.h, p. Ej .:

#define BOOST_ALL_DYN_LINK

18

Para configurar impulso usar la cabecera de configuración de usuario

<boost/config/user.hpp> 

Entonces sólo tiene que buscar las líneas de enlace dinámico y cambio en la configuración deseada

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