Boost logo

Boost Users :

Subject: Re: [Boost-users] Building boost with custom gcc/g++
From: Steve Lorimer (steve.lorimer_at_[hidden])
Date: 2013-01-08 22:23:35


On 8 January 2013 18:56, narjunkumar <narjunkumar_at_[hidden]> wrote:

>
> What seems to be happening in my case is, it cannot find any gcc or any
> toolset in PATH. I am not sure if gcc should be in PATH. i.e if "which gcc"
> should give an output.

gcc via $PATH is the system gcc (version 4.3 or something I think); the gcc
boost / b2 uses is the gcc in user_config.jam (this can be seen not from
the bootstrap.log output; but from the output of b2) - I'm using 4.7.2

It eventually defaults to cc toolset and it takes the
> environment variables CC in that case. (as shown in bootstrap.log)
>
> Could you just tell what do you get in your bootstrap.log? What is the
> toolset it seems to be using - is it taking from your custom gcc path /
> just
> whatever gcc it finds in "which gcc". Also what is the version of boost
> you
> have?
>
>
Below is the log, I'm using 1.51

###
### Using 'gcc' toolset.
###
rm -rf bootstrap
mkdir bootstrap
gcc -o bootstrap/jam0 command.c compile.c constants.c debug.c function.c
glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c
make1.c object.c option.c output.c parse.c pathunix.c regexp.c rules.c
scan.c search.c subst.c timestamp.c variable.c modules.c strings.c
filesys.c builtins.c pwd.c class.c native.c md5.c w32_getreg.c
modules/set.c modules/path.c modules/regex.c modules/property-set.c
modules/sequence.c modules/order.c execunix.c fileunix.c
./bootstrap/jam0 -f build.jam --toolset=gcc --toolset-root= clean
...found 1 target...
...updating 1 target...
...updated 1 target...
./bootstrap/jam0 -f build.jam --toolset=gcc --toolset-root=
...found 50 targets...
...updating 3 targets...
[MKDIR] bin.linuxx86_64
[COMPILE] bin.linuxx86_64/b2
[COPY] bin.linuxx86_64/bjam
...updated 3 targets...

---------------------

So I ripped out the relevant details from my scripts and ran them from the
command line. The following, if I literally just copy-paste it to my linux
command line, works. If it doesn't for you, then perhaps there is something
wrong with your environment?

Note you will obviously have to change the first few lines to specify your
$PREFIX and your GCC 4.7.2 location
Note also it relies on boost_1_51_0.tar.gz being in the current directory.

---------------------

# this section you will have to change to correctly specify your $PREFIX
and your compiler version/location
export PREFIX=/hostname/trading/sdk/
export GLIBC_VER=`/lib/libc.so.6 | head -n1 | cut -f7 -d' '`
export MACHINE_ARCH=`/bin/arch`
export KERNEL_NAME=`uname -s | tr A-Z a-z`
export GCCVER=gcc-4.7.2
export COMPDIR=${PREFIX}/${MACHINE_ARCH}/${GLIBC_VER}/${GCCVER}/bin

# store current dir as the external build root dir
export BUILD_DIR=`pwd`
pushd $BUILD_DIR > /dev/null

# override compiler env vars
export AR="$COMPDIR/ar"
export CC="$COMPDIR/gcc"
export CPP="$COMPDIR/gcc -E"
export CXX="$COMPDIR/g++"
export CXXCPP="$COMPDIR/g++ -E"

# boost version and where to get it
export BOOST_VER=1.51.0

# this is for default and pic builds - here I show only the default (which
will be for statically linked libs)
 export TARGET_BUILD_CONF=Def

# create subdirectory for specific build configuration
mkdir -p ${GCCVER}_${TARGET_BUILD_CONF}
pushd ${GCCVER}_${TARGET_BUILD_CONF} > /dev/null

# unpack source code
tar -xf ../boost_${BOOST_DL_VERSION}.tar.gz

pushd boost_${BOOST_DL_VERSION}

# add your custom compiler to the end of the boost jam config file
cat <<EOF > ./tools/build/v2/user-config.jam
using gcc : : $COMPDIR/g++ ;
EOF

# bootstrap the build
./bootstrap.sh --prefix=${PREFIX} --with-libraries=filesystem,regex,system

# build it
./b2 --toolset=gcc

---------------------

The output from pasting the above to the command line is as follows:

---------------------

$ ls -1 boost_1_51_0.tar.gz
boost_1_51_0.tar.gz
$ # this section you will have to change to correctly specify your $PREFIX
and your compiler version/location
$ export PREFIX=/hostname/trading/sdk/
$ export GLIBC_VER=`/lib/libc.so.6 | head -n1 | cut -f7 -d' '`
$ export MACHINE_ARCH=`/bin/arch`
$ export KERNEL_NAME=`uname -s | tr A-Z a-z`
$ export GCCVER=gcc-4.7.2
$ export COMPDIR=${PREFIX}/${MACHINE_ARCH}/${GLIBC_VER}/${GCCVER}/bin
$
$ # store current dir as the external build root dir
$ export BUILD_DIR=`pwd`
$ pushd $BUILD_DIR > /dev/null
$
$ # override compiler env vars
$ export AR="$COMPDIR/ar"
$ export CC="$COMPDIR/gcc"
$ export CPP="$COMPDIR/gcc -E"
$ export CXX="$COMPDIR/g++"
$ export CXXCPP="$COMPDIR/g++ -E"
$
$ # boost version and where to get it
$ export BOOST_VER=1.51.0
$
$ # this is for default and pic builds - here I show only the default
(which will be for statically linked libs)
$ export TARGET_BUILD_CONF=Def
$
$ # create subdirectory for specific build configuration
$ mkdir -p ${GCCVER}_${TARGET_BUILD_CONF}
$ pushd ${GCCVER}_${TARGET_BUILD_CONF} > /dev/null
$
$ # unpack source code
$ tar -xf ../boost_${BOOST_DL_VERSION}.tar.gz
$
$ pushd boost_${BOOST_DL_VERSION}
~/build.scripts/gcc-4.7.2_Def/boost_1_51_0 ~/build.scripts/gcc-4.7.2_Def
~/build.scripts ~/build.scripts ~/build.scripts ~/build.scripts
~/build.scripts/gcc-4.7.2_Def ~/build.scripts ~/build.scripts
~/build.scripts/gcc-4.7.2_Def ~/build.scripts ~/build.scripts
~/build.scripts/gcc-4.7.2_Def ~/build.scripts ~/build.scripts
~/build.scripts ~/build.scripts ~/build.scripts ~/build.scripts
~/build.scripts/gcc-4.7.2_Def ~/build.scripts ~/build.scripts
~/build.scripts ~/build.scripts ~/build.scripts ~/build.scripts
$
$ # add your custom compiler to the end of the boost jam config file
$ cat <<EOF > ./tools/build/v2/user-config.jam
> using gcc : : $COMPDIR/g++ ;
> EOF
$
$ # bootstrap the build
$ ./bootstrap.sh --prefix=${PREFIX} --with-libraries=filesystem,regex,system
Building Boost.Build engine with toolset gcc...
tools/build/v2/engine/bin.linuxx86_64/b2
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...

Bootstrapping is done. To build, run:

    ./b2

To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help

   - Getting started guide:
     http://www.boost.org/more/getting_started/unix-variants.html

   - Boost.Build documentation:
     http://www.boost.org/boost-build2/doc/html/index.html

$
$ # build it
$ ./b2 --toolset=gcc

Building the Boost C++ Libraries.

Performing configuration checks

    - has_icu builds : no

Component configuration:

    - chrono : not building
    - context : not building
    - date_time : not building
    - exception : not building
    - filesystem : 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 : building
    - serialization : not building
    - signals : not building
    - system : building
    - test : not building
    - thread : not building
    - timer : not building
    - wave : not building

...patience...
...found 676 targets...
...updating 90 targets...
common.mkdir stage
common.mkdir stage/lib
common.mkdir bin.v2/libs/filesystem
common.mkdir bin.v2/libs/filesystem/build
common.mkdir bin.v2/libs/filesystem/build/gcc-4.7.2
common.mkdir bin.v2/libs/filesystem/build/gcc-4.7.2/release
common.mkdir bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/codecvt_error_category.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/operations.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/path.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/path_traits.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/portability.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/unique_path.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/utf8_codecvt_facet.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/windows_file_codecvt.o
common.mkdir bin.v2/libs/system
common.mkdir bin.v2/libs/system/build
common.mkdir bin.v2/libs/system/build/gcc-4.7.2
common.mkdir bin.v2/libs/system/build/gcc-4.7.2/release
common.mkdir bin.v2/libs/system/build/gcc-4.7.2/release/threading-multi
gcc.compile.c++
bin.v2/libs/system/build/gcc-4.7.2/release/threading-multi/error_code.o
gcc.link.dll
bin.v2/libs/system/build/gcc-4.7.2/release/threading-multi/libboost_system.so.1.51.0
gcc.link.dll
bin.v2/libs/filesystem/build/gcc-4.7.2/release/threading-multi/libboost_filesystem.so.1.51.0
common.copy stage/lib/libboost_filesystem.so.1.51.0
ln-UNIX stage/lib/libboost_filesystem.so
common.mkdir bin.v2/libs/regex/build/gcc-4.7.2/release
common.mkdir bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/c_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/cpp_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/cregex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/fileiter.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/icu.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/instances.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/posix_api.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/regex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/regex_debug.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/regex_raw_buffer.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/regex_traits_defaults.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/static_mutex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/w32_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/wc_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/wide_posix_api.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/winstances.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/usinstances.o
gcc.link.dll
bin.v2/libs/regex/build/gcc-4.7.2/release/threading-multi/libboost_regex.so.1.51.0
common.copy stage/lib/libboost_regex.so.1.51.0
ln-UNIX stage/lib/libboost_regex.so
common.copy stage/lib/libboost_system.so.1.51.0
ln-UNIX stage/lib/libboost_system.so
common.mkdir bin.v2/libs/system/build/gcc-4.7.2/release/link-static
common.mkdir
bin.v2/libs/system/build/gcc-4.7.2/release/link-static/threading-multi
gcc.compile.c++
bin.v2/libs/system/build/gcc-4.7.2/release/link-static/threading-multi/error_code.o
gcc.archive
bin.v2/libs/system/build/gcc-4.7.2/release/link-static/threading-multi/libboost_system.a
common.copy stage/lib/libboost_system.a
common.mkdir bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static
common.mkdir
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/codecvt_error_category.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/operations.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/path.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/path_traits.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/portability.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/unique_path.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/utf8_codecvt_facet.o
gcc.compile.c++
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/windows_file_codecvt.o
gcc.archive
bin.v2/libs/filesystem/build/gcc-4.7.2/release/link-static/threading-multi/libboost_filesystem.a
common.copy stage/lib/libboost_filesystem.a
common.mkdir bin.v2/libs/regex/build/gcc-4.7.2/release/link-static
common.mkdir
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/c_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/cpp_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/cregex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/fileiter.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/icu.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/instances.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/posix_api.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/regex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/regex_debug.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/regex_raw_buffer.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/regex_traits_defaults.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/static_mutex.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/w32_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/wc_regex_traits.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/wide_posix_api.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/winstances.o
gcc.compile.c++
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/usinstances.o
gcc.archive
bin.v2/libs/regex/build/gcc-4.7.2/release/link-static/threading-multi/libboost_regex.a
common.copy stage/lib/libboost_regex.a
...updated 90 targets...

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    /home/sydapps/build.scripts/gcc-4.7.2_Def/boost_1_51_0

The following directory should be added to linker library paths:

    /home/sydapps/build.scripts/gcc-4.7.2_Def/boost_1_51_0/stage/lib

$



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net