2013-04-23 125 views
0

嘗試我的項目靜態地boost.log上MSVC 10.0鏈接的時候,我發現了以下(還有更多)錯誤:boost.log錯誤鏈接靜態

1>libboost_log-vc100-mt-gd-1_53.lib(attribute_name.obj) : error 
LNK2001: unresolved external symbol "**__declspec(dllimport)** public: 
__thiscall std::_Container_base::~_Container_base(void)" ([email protected]@@[email protected]) 
1>libboost_log-vc100-mt-gd-1_53.lib(text_file_backend.obj) : error 
LNK2001: unresolved external symbol "**__declspec(dllimport)** public: 
__thiscall std::_Container_base::~_Container_base(void)" ([email protected]@@[email protected]) 

注意,該項目還可以鏈接到增強系統,文件系統和線程庫。

1>  Searching ../lib/\libboost_system-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_date_time-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_regex-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_thread-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_chrono-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_log-vc100-mt-gd-1_53.lib: 
1>  Searching ../lib/\libboost_filesystem-vc100-mt-gd-1_53.lib: 

我的項目沒有定義BOOST_ALL_DYN_LINKBOOST_LOG_DYN_LINK宏,所以我不希望看到的__declspec簽名,這我想是最終的問題。我是否缺少靜態正確鏈接此庫所需的內容?

更新

我刪除了預編譯的頭對我的項目,並進行了「乾淨」的,一切連接正常。預編譯頭文件是否有可能導致項目靜態鏈接到CRT?

+0

'BOOST_ALL_DYN_LINK'強制* Boost *庫動態鏈接,而您看到的'__declspec'簽名與標準C++庫有關,該庫是動態鏈接的。 PCH不能改變CRT連接,它只是MT/MD編譯器選項,但IDE中通常存在一些故障,所以清理和重建總是很好的。 – 2013-04-23 12:11:32

+0

@IgorR。總是要學習。感謝您的幫助,隨時重新發布答案。 – jwalk 2013-04-23 12:27:48

+0

我認爲它不能回答你的問題,因爲我不知道你的項目設置有什麼問題。 – 2013-04-23 16:10:09

回答

0

您可能需要鏈接log_setup先,然後filesystem之前log等等,這是提升鏈接代碼在我CMakeLists.txt

set(USED_BOOST_LIBS ${Boost_LOG_SETUP_LIBRARY} ${Boost_LOG_LIBRARY} 
    ${Boost_FILESYSTEM_LIBRARY} 
    ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY} 
    ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY} 
) 

... 
target_link_libraries(myexe ${USED_BOOST_LIBS}) 

它工作正常,我都在MSVC 14.0和gcc 4.8.You能嘗試一下。