2010-03-25 28 views
26

Tôi đã biên soạn thư viện nâng cao và nhận các thư này.Làm cách nào để liên kết tới libs động?

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

Trong Visual Studio, tôi đã viết một ứng dụng thử nghiệm bằng thư viện chuỗi tăng. Dựa trên các thiết lập hệ mã nó yêu cầu những chỉ có bốn libs (như đa luồng gỡ lỗi, đa luồng, đa luồng gỡ lỗi dll, và đa luồng 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 

Bây giờ câu hỏi của tôi là làm thế nào tôi có thể liên kết ứng dụng của tôi với 2 libs khác để rằng nó sử dụng các 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 

Câu hỏi 2. g là gì?

Trả lời

9
  1. Tệp .lib được liên kết tĩnh, trong khi tệp .dll được liên kết động. Tôi tin rằng đó là một thiết lập dự án 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. 

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

+6

nguồn tốt hơn: http: //www.boost .org/doc/libs/1_42_0/more/getting_started/windows.html # đặt tên thư viện –

28

Bạn có thể buộc Boost sử dụng DLL bằng cách định nghĩa BOOST_ALL_DYN_LINK - hoặc trong bạn Cài đặt tiền xử lý C++ hoặc theo số #define trong tiêu đề được biên dịch trước stdafx.h của bạn, ví dụ:

#define BOOST_ALL_DYN_LINK

18

Để cấu hình tăng sử dụng tiêu đề sử dụng cấu hình

<boost/config/user.hpp> 

Sau đó chỉ cần tìm kiếm các đường liên kết động và thay đổi cấu hình của bạn mong muốn

// 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 
Các vấn đề liên quan