Boost library will cross compile the source code to download books

Time:2021-1-9

 

A good memory is not as good as a bad pen. I’ll record the transplant of boost library.

 

1. Download address of boost library version 1.66.0, with book c + + boost library development guide:

 https://download.csdn.net/download/qq_37372700/12960498

 

2. Cross compiling

Current environment:

Compile script:

my_compile_boost.sh:

#xcompile_boost.sh

mfile=project-config.jam

if [ -e ${mfile} ];then
    rm ${mfile}
    echo "rm ${mfile}"
fi

#--With libraries specifies which boost libraries to compile. If all, all will be compiled,
#If you just want to compile part of the library, you can write the name of the library and separate it with a, sign

#--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

 

Then move the required library files to the embedded system (select according to the needs of your own library, and consider the embedded disk size),

Or you can directly put the library files into the root file system of the Ubuntu host, re create the next image, and then burn the system to the embedded device.

Then create several symbolic links, as shown by the red arrow in the following figure.

 

3. Test code

Current environment:

my_boost_test.cpp:

// test1 -- ( boost::this_thread::sleep() ) -- Success

#include 
#include  

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

 

 

 

 

 

.

 

Recommended Today

Process management of simulating Supervisor

preface Simulation supervisor process management demo (simple implementation) Yes, it’s wheel building! The purpose is to learn! Screenshot: In the figure, I have implemented oneCopyThe function of the subprocess. If it is used to increase or decrease the number of consumers in AMQP, I think it will be very useful. realization 1. Start the child […]