天天看點

Linux下交叉編譯環境配置及boost庫的配置

一:首先安裝好NDK。

1.1NDK下載下傳位址:

https://developer.android.com/ndk/index.html

1.2下載下傳後的配置方式參考下文:

http://blog.sina.com.cn/s/blog_4a0a39c30101q1u4.html

二:配置boost庫的交叉編譯

2.1 boost庫下載下傳位址

http://www.boost.org/users/download/

2.2 下載下傳後的配置方式:

2.2.1. 解壓boost壓縮包

2.2.2 進入目錄執行./bootstrap.sh, 此時形成bjam檔案和project-config.jam

2.2.3. 編輯project-config.jam, 僅修改using gcc這行。因為我使用的是,是以将其改以下即可:

using gcc : arm : arm-linux-androideabi-g++ ; (注意空格)

2.2.4. 執行./bjam 或者 ./bjam stage –layout=tagged –build-type=complete (好像是後者生成的庫檔案更多)

2.2.5. 形成的靜态和動态庫檔案就在stage目錄下.

2.2.6 編寫一個測試文檔

test.cpp

#include <boost/thread.hpp>
#include <iostream>
void wait(int seconds)
{
boost::this_thread::sleep(boost::posix_time::seconds(seconds));
}
void thread()
{
for (int i = ; i < ; ++i)
{
wait();
std::cout << i << std::endl;
}
}
int main()
{
boost::thread t(thread);
t.join();
}
           

2.2.7 編譯該測試文檔;輸入指令

至此如果編譯成功,說明boost庫的交叉編譯環境下的配置成功了

繼續閱讀