Search code examples
c++linuxboostpowerpc

Cross Compile Boost library for PowerPC architecture


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:

  1. Add the line "using gcc : power : ppc_4xx-g++ ;" to the file user-config.jam
  2. Run ./bootstrap.sh --prefix=BoostPowerPC in root directory.
  3. 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

  1. --sysroot=: This is the root directory of all the includes and libraries used by the compiler.

  2. -B : Using this we can add a search path for the compiler.

I tried both and it didn't help. Any suggestions ?


Solution

  • 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.