標籤:os 檔案 問題 代碼 sp amp linux line on
最近項目剛開始起動,一些底層庫編寫用到boost,在編譯過程中遇到一些奇怪問題,在此記錄下
1.庫的串連順序問題,比如a依賴b,串連的時候要先串連a,eg -L -a -b;
2.boost庫的問題,庫裡面用到boost,產生庫檔案沒有問題,但是到工程檔案產生引用到庫檔案的時候,提示:
undefined reference to `boost::system::get_system_category()‘
undefined reference to `boost::system::get_generic_category()‘
查看了原始碼,原來需要定義宏 BOOST_SYSTEM_NO_DEPRECATED
# 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
所以在產生庫檔案時候(我的是libkernel.a)要定義這個宏,
boost system庫確實沒有找到這幾個函數,所以你的工程最好也定義這個宏,不要引用這些方法。
linux環境下編譯問題