问题
I am trying to cross compile Boost library (Thread, System) for PowerPC architecture. I followed the below steps but facing problems.
I run a shell script which sets up my toolchain. The compiler ppc_4xx-g++ is visible at the shell.
Steps followed:
- Add the line "using gcc : power : ppc_4xx-g++ ;" to the file user-config.jam
- Run ./bootstrap.sh --prefix=BoostPowerPC in root directory.
- Run ./b2 install --build-dir=BoostPowerPC toolset=gcc-power --with-thread --with-system stage
Result: All the directories gets created but compilation fails. I can't attach the error log (Please send me your email so that I can send you the error log if you need). Below is the snapshot of the error log.
Component configuration:
- atomic : not building
- chrono : not building
- context : not building
- date_time : not building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : not building
- math : not building
- mpi : not building
- program_options : not building
- python : not building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : building
- test : not building
- thread : building
- timer : not building
- wave : not building
...patience...
...found 20376 targets...
...updating 10110 targets...
common.mkdir BoostPowerPC
common.mkdir BoostPowerPC/lib
common.mkdir BoostPowerPC/boost
common.mkdir BoostPowerPC/boost/bin.v2
common.mkdir BoostPowerPC/boost/bin.v2/libs
common.mkdir BoostPowerPC/boost/bin.v2/libs/system
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release
common.mkdir BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi
gcc.compile.c++ BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi/error_code.o
In file included from ./boost/config/select_stdlib_config.hpp:18,
from ./boost/config.hpp:40,
from ./boost/system/config.hpp:13,
from libs/system/src/error_code.cpp:18:
/opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/cstddef:50:28: error: bits/c++config.h: No such file or directory
In file included from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/ios:43,
from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/ostream:45,
from /opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/iterator:70,
from ./boost/iterator.hpp:17,
from ./boost/operators.hpp:86,
from ./boost/system/error_code.hpp:17,
from libs/system/src/error_code.cpp:19:
.
.
.
Its complaining that the file c++config.h is not found. But the file is present in the location /opt/ELDK/4.2/usr/include/c++/4.2.2/powerpc-linux/bits directory
Then I tried to use the tag "include" in the b2 command. But then I get a error that the file cstddef is not found which is present in the directory /opt/ELDK/4.2/usr/include/c++/4.2.2. I think I am over writing the include path.
What do you think is the problem ? Why can't my compiler find the file even if its present ? Any suggestions ?
Update:
I used -d+2 and -q options and below is the result.
"ppc_4xx-g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG -I"." -I"/opt/ELDK/4.2/ppc_4xx/usr/include" -c -o "BoostPowerPC/boost/bin.v2/libs/system/build/gcc-power/release/threading-multi/error_code.o" "libs/system/src/error_code.cpp"
Compilation log:
In file included from ./boost/config/select_stdlib_config.hpp:18,
from ./boost/config.hpp:40,
from ./boost/system/config.hpp:13,
from libs/system/src/error_code.cpp:18:
/opt/ELDK/4.2/ppc_4xx/usr/include/c++/4.2.2/cstddef:50:28: error: bits/c++config.h: No such file or directory
As we can see the the higher directory which has the required file is included and visible to the compiler. I even tried using -L command and specify the root directory. It still didn't help.
I checked the compilation options of ppc_4xx-g++ and 2 options interested me
--sysroot=: This is the root directory of all the includes and libraries used by the compiler.
-B : Using this we can add a search path for the compiler.
I tried both and it didn't help. Any suggestions ?
回答1:
First of all, this is not really a problem with Boost.Build. Which means that it will be easier to fix it by taking your last command (which fails), running it by hand on the command-line, and then adjusting it until it works.
As said already, you should then remove -I"/opt/ELDK/4.2/ppc_4xx/usr/include"
from your command line.
Normally, the compiler should find its own header files automatically. Two possible things can interfere with that:
- You are running ppc_4xx-g++ from a different place from where compiler headers are actually installed. Using
which ppc_4xx-g++
do find out. You can also add-v
to compiler invocation to check which directories it is searching in. - The compiler is improperly built in unknown ways. Pedantically speaking, 'ppc_4xx' is not even valid target triplet, but I don't know whether that would break compilation in the way you have described.
As the last resort, you can try --sysroot=/opt/ELDK/4.2/ppc_4xx/usr/bin
.
回答2:
Your include paths are not correct, and error clearly denotes this, as each toolchain got its own path, make sure your include path for STL etc are updated to point to new location. It should solve your problem!
回答3:
The problem was because of a bug in the compiler. It couldn't recursively search for directories to find the include folders. When I manually provided the additional include path, it rejected it stating redundant include path (since it was in the same directory structure) - Found this by using -v option. Then I created a directory, created a soft link to the directory which had the necessary include files and included this new directory in my include path (Workaround). This worked and I could generate the libraries.
Eg: The include files were present in the directory abc/include/xyz/include which the compiler was not accepting as I had already specified the path abc/include. Hence I created a directory alias and linked it to abc/include/xyz/include. Then I included ./alias as one of the include paths and it worked. This was a known compiler issue which is fixed in later versions, I think in 4.6
PS: The idea was not mine but found a similar post online which helped me.
来源:https://stackoverflow.com/questions/14974902/cross-compile-boost-library-for-powerpc-architecture