2010-03-25 14 views
26

मैंने बूस्ट लिब संकलित किया और इन्हें मिला।डायनामिक बूस्ट libs से कैसे लिंक करें?

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

विजुअल स्टूडियो में, मैंने बूस्ट थ्रेड लाइब्रेरी का उपयोग करके एक टेस्ट ऐप लिखा है। कोड पीढ़ी सेटिंग के आधार पर यह

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 

अब मेरे सवाल का कैसे मैं इतना अन्य 2 libs करने के लिए अपने एप्लिकेशन लिंक कर सकते हैं (डिबग, बहु सूत्रण, बहु सूत्रण डिबग DLL, और बहु ​​सूत्रण dll multithreading) की तरह ही इन चार libs के लिए पूछता है कि यह डीएलएस का उपयोग करता है?

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. जी, एस क्या है?

उत्तर

9
  1. .lib फ़ाइलें स्थिर रूप से लिंक की गई हैं, जबकि .dll फ़ाइलें गतिशील रूप से जुड़ी हैं। मेरा मानना ​​है कि यह एक वीसी परियोजना सेटिंग है।

 
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

+6

बेहतर स्रोत: http: //www.boost .org/doc/libs/1_42_0/अधिक/getting_started/windows.html # पुस्तकालय का नाम बदलने –

28

आप BOOST_ALL_DYN_LINK को परिभाषित करते हुए DLLs उपयोग करने के लिए बूस्ट मजबूर कर सकते हैं - या तो अपनी आपके stdafx.h पूर्व-संकलित शीर्षलेख में सी ++ प्रीप्रोसेसर सेटिंग्स या #define द्वारा, उदाहरण:

#define BOOST_ALL_DYN_LINK

18

कॉन्फ़िगर करने के लिए बढ़ावा उपयोगकर्ता config हैडर

<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 
संबंधित मुद्दे