好記性不如爛筆頭,BOOST庫的移植,我也記錄一下,
1. BOOST庫 版本1.66.0 下載地址, 附書籍C++ BOOST庫開發指南:
2.交叉編譯:
當前環境:

編譯腳本:

my_compile_boost.sh:
#xcompile_boost.sh
mfile=project-config.jam
if [ -e ${mfile} ];then
rm ${mfile}
echo "rm ${mfile}"
fi
#--with-libraries指定編譯哪些boost庫,all的話就是全部編譯,
# 只想編譯部分庫的話就把庫的名稱寫上,之間用 , 號分隔即可
#--with-libraries=system,filesystem,regex \
./bootstrap.sh \
--with-libraries=all \
--prefix=/home/lmw/open_lib/boost/boost_stuphere
if [ -e ${mfile} ];then
mhost="mips-linux-gnu-g++ -fPIC"
sed -i "/using gcc/c using gcc : mips : ${mhost} ; " ${mfile}
fi
echo "After 5s start compile"
sleep 5s
./b2
echo "Afer 5s start install"
sleep 5s
./b2 install

3.測驗代碼
當前環境:

my_boost_test.cpp:
// test1 -- ( boost::this_thread::sleep() ) -- Success
#include <boost/thread/thread.hpp>
#include <iostream>
void wait(int seconds)
{
boost::this_thread::sleep(boost::posix_time::seconds(seconds));
}
void thread()
{
for (int i = 0; i < 5; ++i)
{
wait(1);
std::cout << i << std::endl;
}
}
int main()
{
boost::thread t(thread);
t.join();
}
makefile:
.PHONY: DOIT
DOIT:
mips-linux-gnu-g++ -I. my_boost_test.cpp -L./lib -lboost_thread -lboost_system -o boost_app
.
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/179023.html
標籤:其他
