2013-10-11 47 views
1
obj\Debug\src\SQLite3DB.o||In function _static_initialization_and_destruction_0:| 
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|222|undefined reference to boost::system::generic_category()| 
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|223|undefined reference to boost::system::generic_category()| 
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|224|undefined reference to boost::system::system_category()| 
||=== Build finished: 3 errors, 0 warnings (0 minutes, 4 seconds) ===| 

上面是我的完整的錯誤消息後,包括boost/filesystem.hpp我的項目。我看到一些帖子說,加入-lboost_system可能會解決這個問題,但我不知道在CodeBlocks中該怎麼做!
我已經花了一天時間解決這個問題。謝謝你的幫助!未定義的引用「boost :: system :: system_category()」

+0

可能重複[?如何鏈接到與代碼::塊庫(http://stackoverflow.com/questions/5862757/how-do-i-link-to- a-library-with-codeblocks) –

+0

我只是在鏈接器中添加-lboost_system,但它出現了這個錯誤「沒有這樣的文件或者勝利」。我該怎麼辦? – yphs

回答

2

右鍵單擊項目名稱;點擊「Build options ...」;轉到「鏈接器設置」;點擊「添加」;找到庫並添加它。

enter image description here enter image description here enter image description here enter image description here

此外,您也可以添加一些自定義變量來簡化調試/ release和32位/ 64位的目標選項的管理。我會把它留給你。


編輯

這裏是error_code.hpp錯誤代碼:

# ifndef BOOST_SYSTEM_NO_DEPRECATED 
    inline const error_category & get_system_category() { return system_category(); } 
    inline const error_category & get_generic_category() { return generic_category(); } 
    inline const error_category & get_posix_category() { return generic_category(); } 
    static const error_category & posix_category = generic_category(); 
    static const error_category & errno_ecat  = generic_category(); 
    static const error_category & native_ecat = system_category(); 
# endif 

正如你所看到的,定義BOOST_SYSTEM_NO_DEPRECATED將其禁用。我已經測試過,它的工作原理。這將編譯:

#define BOOST_SYSTEM_NO_DEPRECATED 
#include <boost/system/error_code.hpp> 

int main(void) 
{ 

} 
+0

.. \ .. \ .. \ .. \ .. Boost \ 1_54_0 \ VC \ 11.0 \ bin.v2 \ libs \ system \ build \ msvc-11.0 \ debug \ link-static \ threading-multi \ libboost_system-vc110-mt -gd-1_54.lib - 添加到鏈接器設置後它仍然得到相同的錯誤! – yphs

+0

@ user2344692:我已經更新了答案。 – hauzer

相關問題