androidstudio編譯boost線程庫報錯 undefined reference to boost::thread incompatible target

AndroidStudio編譯boost::thread報錯

報錯信息

boost_1_72_0/android_build/lib/libboost_thread-clang-mt-1_72.a(thread.o): incompatible target
boost/thread/detail/thread.hpp:716: error: undefined reference to ‘boost::thread::native_handle()’

分析解決辦法:
incompatible target 意思是引入的庫CPU架構(指令集)不兼容。
因爲編譯庫用的命令是 toolset=clang-arm64,也就是隻能適用於 abiFilters "arm64-v8a"

b2 target-os=android toolset=clang-arm64 link=static --stagedir=android_build

修改配置爲以下則編譯通過了。

defaultConfig {
    ndk {
        abiFilters  "arm64-v8a"
    }
}

踩坑:
CMakeLists.txt中添加 add_definitions (-lpthread) 編譯參數是無效的解決方法!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章