Cross-compiling boost for Windows on Linux - c++

I'm trying to create mingw binaries for boost on a Linux machine. The mingw compiler is present on my system as /usr/bin/i586-mingw32msvc-g++ and I have been able to create a simple HelloWorld.exe application.
Here is an exact list of my actions:
$ tar xvf boost_1_46_1.tar.gz
$ cd boost_1_46_1/
$ echo "using gcc : 4.4.4: i586-mingw32msvc-g++ ;" > user-config.jam
$ ./bootstrap.sh
$ ./bjam toolset=gcc target-os=windows
The result is this:
Building the Boost C++ Libraries.
...found 83 targets...
...updating 9 targets...
common.mkdir bin.v2
common.mkdir bin.v2/libs
common.mkdir bin.v2/libs/regex
common.mkdir bin.v2/libs/regex/build
common.mkdir bin.v2/libs/regex/build/gcc-mingw-4.4.4
common.mkdir bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug
common.mkdir bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows
gcc.compile.c++ bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows/has_icu_test.o
In file included from /usr/include/unicode/pwin32.h:123,
from /usr/include/unicode/umachine.h:47,
from /usr/include/unicode/uversion.h:47,
from libs/regex/build/has_icu_test.cpp:12:
/usr/include/inttypes.h:290: warning: ISO C++ 1998 does not support ‘long long’
/usr/include/inttypes.h:291: warning: ISO C++ 1998 does not support ‘long long’
libs/regex/build/has_icu_test.cpp: In function ‘int main()’:
libs/regex/build/has_icu_test.cpp:24: warning: unused variable ‘c’
gcc.link bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows/has_icu.exe
/usr/lib/gcc/i586-mingw32msvc/4.4.4/../../../../i586-mingw32msvc/bin/ld: cannot find -licuuc
collect2: ld returned 1 exit status
"i586-mingw32msvc-g++" -L"/usr/bin" -L"/usr/lib" -Wl,-R -Wl,"/usr/bin" -Wl,-R -Wl,"/usr/lib" -Wl,-rpath-link -Wl,"/usr/bin" -Wl,-rpath-link -Wl,"/usr/lib" -o "bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows/has_icu.exe" -Wl,--start-group "bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows/has_icu_test.o" -Wl,-Bstatic -Wl,-Bdynamic -licuuc -licui18n -licudata -Wl,--end-group -g
...failed gcc.link bin.v2/libs/regex/build/gcc-mingw-4.4.4/debug/target-os-windows/has_icu.exe...
...failed updating 1 target...
...updated 8 targets...
Performing configuration checks
- has_icu builds : no
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
...found 8 targets...
...updating 6 targets...
common.mkdir bin.v2/libs/math
common.mkdir bin.v2/libs/math/config
common.mkdir bin.v2/libs/math/config/gcc-mingw-4.4.4
common.mkdir bin.v2/libs/math/config/gcc-mingw-4.4.4/debug
common.mkdir bin.v2/libs/math/config/gcc-mingw-4.4.4/debug/target-os-windows
gcc.compile.c++ bin.v2/libs/math/config/gcc-mingw-4.4.4/debug/target-os-windows/has_gcc_visibility.o
cc1plus: warnings being treated as errors
libs/math/config/has_gcc_visibility.cpp: In function ‘int main()’:
libs/math/config/has_gcc_visibility.cpp:13: error: visibility attribute not supported in this configuration; ignored
"i586-mingw32msvc-g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -Werror -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -I"." -c -o "bin.v2/libs/math/config/gcc-mingw-4.4.4/debug/target-os-windows/has_gcc_visibility.o" "libs/math/config/has_gcc_visibility.cpp"
...failed gcc.compile.c++ bin.v2/libs/math/config/gcc-mingw-4.4.4/debug/target-os-windows/has_gcc_visibility.o...
...failed updating 1 target...
...updated 5 targets...
- ../config//has_gcc_visibility builds : no
...found 46 targets...
...updating 1 target...
gcc.compile.c++ bin.v2/libs/math/config/gcc-mingw-4.4.4/debug/target-os-windows/has_long_double_support.o
...updated 1 target...
- ../config//has_long_double_support builds : yes
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
************************************************************
Trying to build Boost.Thread with pthread support.
If you need pthread you should specify the paths.
You can specify them in site-config.jam, user-config.jam
or in the environment.
For example:
PTW32_INCLUDE=C:\Program Files\ptw32\Pre-built2\include
PTW32_LIB=C:\Program Files\ptw32\Pre-built2\lib
************************************************************
/home/francis/orig/boost_1_46_1/tools/build/v2/build/virtual-target.jam:1079: in virtual-target.register-actual-name from module virtual-target
error: Duplicate name of actual target: <pstage/lib>libboost_date_time.a
error: previous virtual target { common%common.copy-libboost_date_time.a.STATIC_LIB { gcc%gcc.archive-libboost_date_time.a.STATIC_LIB { gcc%gcc.compile.c++-gregorian/greg_month.o.OBJ { gregorian/greg_month.cpp.CPP } } { gcc%gcc.compile.c++-gregorian/greg_weekday.o.OBJ { gregorian/greg_weekday.cpp.CPP } } { gcc%gcc.compile.c++-gregorian/date_generators.o.OBJ { gregorian/date_generators.cpp.CPP } } } }
error: created from ./stage-proper
error: another virtual target { common%common.copy-libboost_date_time.a.STATIC_LIB { gcc%gcc.archive-libboost_date_time.a.STATIC_LIB { gcc%gcc.compile.c++-gregorian/greg_month.o.OBJ { gregorian/greg_month.cpp.CPP } } { gcc%gcc.compile.c++-gregorian/greg_weekday.o.OBJ { gregorian/greg_weekday.cpp.CPP } } { gcc%gcc.compile.c++-gregorian/date_generators.o.OBJ { gregorian/date_generators.cpp.CPP } } } }
error: created from ./stage-proper
error: added properties: <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <runtime-debugging>off <variant>release
error: removed properties: <debug-symbols>on <inlining>off <optimization>off <runtime-debugging>on <variant>debug
/home/francis/orig/boost_1_46_1/tools/build/v2/build/virtual-target.jam:490: in actualize-no-scanner from module object(file-target)#3884
/home/francis/orig/boost_1_46_1/tools/build/v2/build/virtual-target.jam:135: in object(file-target)#3884.actualize from module object(file-target)#3884
/home/francis/orig/boost_1_46_1/tools/build/v2/build-system.jam:748: in load from module build-system
/home/francis/orig/boost_1_46_1/tools/build/v2/kernel/modules.jam:283: in import from module modules
/home/francis/orig/boost_1_46_1/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
/home/francis/orig/boost_1_46_1/boost-build.jam:17: in module scope from module
It says libicu is not found on my system, but according to Synaptic Package Manage I have the libicu-dev package installed.
I'm not sure how to get it right. Can anyone help?
Update 1
Following #Luke's recoommendation I now gcc-mingw toolset. So now my build instructions look like this:
tar xvf boost_1_46_1.tar.gz
cd boost_1_46_1/
echo "using gcc : 4.4.4: i586-mingw32msvc-g++ ;" > user-config.jam
./bootstrap.sh
./bjam toolset=gcc-mingw target-os=windows
Which leads to the following errors:
error: toolset gcc initialization:
error: version 'mingw' requested but 'g++-mingw' not found and version '4.4.5' of default 'g++' does not match
error: initialized from
/home/francis/orig/boost-mingw/boost_1_46_1/tools/build/v2/build/toolset.jam:38: in toolset.using from module toolset
/home/francis/orig/boost-mingw/boost_1_46_1/tools/build/v2/build-system.jam:481: in process-explicit-toolset-requests from module build-system
/home/francis/orig/boost-mingw/boost_1_46_1/tools/build/v2/build-system.jam:561: in load from module build-system
/home/francis/orig/boost-mingw/boost_1_46_1/tools/build/v2/kernel/modules.jam:283: in import from module modules
/home/francis/orig/boost-mingw/boost_1_46_1/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
/home/francis/orig/boost-mingw/boost_1_46_1/boost-build.jam:17: in module scope from module
Update 2
I have also tried specifying gcc-mingw in the user-config.jam file. Then my build instructions look like this:
tar xvf boost_1_46_1.tar.gz
cd boost_1_46_1/
echo "using gcc-mingw : 4.4.4: i586-mingw32msvc-g++ ;" > user-config.jam
./bootstrap.sh
./bjam toolset=gcc-mingw target-os=windows
Which leads to:
error: version 'mingw' requested but 'g++-mingw' not found and version '4.4.5' of default 'g++' does not match
Update 3
Specifying g++-mingw in the user-config.jam file:
using g++-mingw : 4.4.4: i586-mingw32msvc-g++ ;
...leads to the same error.

I got similar error messages. Eventually I was able to compile it using exactly the following commands:
$ echo "using gcc : : i686-w64-mingw32-g++ ;" > user-config.jam
$ ./bootstrap.sh
$ ./b2 --user-config=user-config.jam toolset=gcc-mingw target-os=windows release
I believe your problem is that you don't specify the "--user-config=user-config.jam" parameter. The next problem I encountered was that there will be a name conflict unless I specify either debug or release build (--layout=tagged or --layout=versioned might work also).

Cross-compiling boost 1.72.0 for Windows on Ubuntu 18.04
Install MinGW
$ sudo apt install mingw-w64 mingw-w64-tools
$ sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
$ sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
$ sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
$ sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
32-bit Compilation (install path: ./boost-x86)
$ echo "using gcc : : i686-w64-mingw32-g++ ;" > user-config.jam
$ ./bootstrap.sh
$ ./b2 --user-config=./user-config.jam --prefix=./boost-x86 target-os=windows address-model=32 variant=release install
64-bit Compilation (install path: ./boost-x64)
$ echo "using gcc : : x86_64-w64-mingw32-g++ ;" > user-config.jam
$ ./bootstrap.sh
$ ./b2 --user-config=./user-config.jam --prefix=./boost-x64 target-os=windows address-model=64 variant=release install

I had some difficulty with this too, but it seems to be working for me now. To be clear, I'm cross compiling on Linux for Windows.
in user-config.jam:
using gcc : mingw32 : i686-w64-mingw32-g++ ;
Note that the second term "mingw32" is an arbitrary "version" tag. The toolset flag combines the compiler name and the version name w/ a dash. So, in my case, gcc-mingw32. The third term is what actually gets invoked ("i686-w64-mingw32-g++"). Obviously your version of mingw's compiler may have a different name.
Here is how I invoked bjam:
./b2 toolset=gcc-mingw32 target-os=windows threadapi=win32 --build-type=complete --prefix=/usr/x86_64-w64-mingw32/local --layout=tagged --without-python -sNO_BZIP2=1 -sNO_ZLIB=1
I got all the interesting flags from Congelli501's answer. But didn't bother with the directory of links approach.

This is the commands I use. I have tested them for boost 1.46 and 1.49.
To begin, create links to the compiler inside /usr/i686-w64-mingw32/bin. You can run this script :
#!/bin/bash
binDir="/usr/bin"
destDir="/usr/i686-w64-mingw32/bin"
cd "$binDir"
mkdir -p "$destDir"
for name in $(ls i686-w64-mingw32*); do
newName=$(echo "$name" | sed -e "s/i686-w64-mingw32-\(.\?\)/\1/")
if [ -f "$destDir/$newName" ]; then
rm "$destDir/$newName"
fi
ln -s "$binDir/$name" "$destDir/$newName"
done
Then, install bjam. On ubuntu / debian, it is included in the package "libboost1.48-dev"
apt-get install libboost1.48-dev
To finish, become root and run
env PATH=/usr/i686-w64-mingw32/bin:$PATH bjam toolset=gcc target-os=windows variant=release threading=multi threadapi=win32 link=static --prefix=/usr/i686-w64-mingw32 -j 4 --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged install
Done !

According to this it looks like you should be using the toolset=gcc-mingw. You have toolset=gcc.

As Luke already mentioned, toolset=gcc-mingw will certainly help.
Your libicu-dev is 99% sure the linux library headers, which is not for mingw. You'll either have to build it yourself or get it from someplace (could be your distribution, otherwise you'll need to build it from source)

I had same problem. Try specifying only a single build variant (i.e., add "variant=Release link=shared runtime-link=shared")

Related

Building Intel Threading Building Blocks fails with Mingw-w64

I am using Mingw-w64 with gcc 10.2 and I am trying to compile Intel Threading Building Blocks on a MSYS2 console. I have been successfully using the build scripts of the older versions before, but the new version with tag "v2021.2.0" offers CMake build only.
I build by running this script on the MSYS2 console:
#!/bin/bash
TBB_DIR=/c/Libraries/TBB
PARALLEL_PROCESSES=1
echo
echo Building Tbb...
echo
rm -rf $TBB_DIR/Build
mkdir $TBB_DIR/Build
cd $TBB_DIR/Build
cmake -DCMAKE_BUILD_TYPE="Release" -S "$TBB_DIR" -B "$TBB_DIR/Build" -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="$TBB_DIR/Install" -DTBB_STRICT=False -DTBB_TEST=False
cd $TBB_DIR/Build
mingw32-make -j $PARALLEL_PROCESSES install
The builds fails and the error is:
In file included from C:/Libraries/TBB/include/oneapi/tbb/detail/_utils.h:26,
from C:/Libraries/TBB/src/tbb/allocator.cpp:21:
C:/Libraries/TBB/include/oneapi/tbb/detail/_machine.h:241:56: error: '_MCW_DN' was not declared in this scope
241 | static constexpr unsigned int X87CW_CONTROL_MASK = _MCW_DN | _MCW_EM | _MCW_RC;
| ^~~~~~~
compilation terminated due to -Wfatal-errors.
Why is this the case? Is Mingw-w64 not supported? Or what am I doing wrong?
I'm able to build TBB 2020.0 with MinGW-w64 on Windows like this (without CMake):
#ARCH=ia32
ARCH=intel64
mingw32-make compiler=gcc arch=$ARCH runtime=mingw tbb tbbmalloc CPLUS="g++ -static-libstdc++ -static-libgcc"

Why is "arm-linux-gnueabi-g++" used when compiling Boost?

I'm attempting to manually compile Boost on Ubuntu Linux 12.04. However, it seems to be attempting to cross-compile, even though I haven't told it to.
These are the commands I used:
git clone https://github.com/boostorg/boost
git checkout boost-1.60.0
git submodule init
git submodule update
cd tools/build/
./bootstrap.sh
sudo ./b2 install --prefix=/usr/local/
cd ../../
sudo b2 -j12 --build-dir=/tmp/build_boost --build-type=complete toolset=gcc address-model=64 architecture=x86 threading=multi runtime-link=shared stage --layout=tagged
The last command fails, giving various compilation errors, all similar to the first one shown below:
gcc.compile.c++ /tmp/build_boost/boost/bin.v2/libs/system/build/gcc-arm/release/address-model-64/architecture-x86/threading-multi/error_code.
arm-linux-gnueabi-g++: error: unrecognized command line option ‘-m64’
"arm-linux-gnueabi-g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC -m64 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG -I"." -c -o "/tmp/build_boost/boost/bin.v2/libs/system/build/gcc-arm/release/address-model-64/architecture-x86/threading-multi/error_code.o" "libs/system/src/error_code.cpp"
...failed gcc.compile.c++ /tmp/build_boost/boost/bin.v2/libs/system/build/gcc-arm/release/address-model-64/architecture-x86/threading-multi/error_code.o...
How do I make sure it uses the native g++ (for x86-64)?
Found the problem: there was a user-config.jam in my home directory (probably stored temporarily during cross-compile tests). I only found out because removing all arm-linux-gnueabi-* files from /usr/bin/ led to the following error:
/home/janito/boost/tools/build/src/tools/gcc.jam:83: in gcc.init from module gcc
error: toolset gcc initialization:
error: provided command 'arm-linux-gnueabi-g++' not found
error: initialized from /home/janito/user-config.jam:45
/home/janito/boost/tools/build/src/build/toolset.jam:43: in toolset.using from module toolset
/home/janito/boost/tools/build/src/build/project.jam:1052: in using from module project-rules
/home/janito/user-config.jam:45: in modules.load from module user-config
/home/janito/boost/tools/build/src/build-system.jam:249: in load-config from module build-system
/home/janito/boost/tools/build/src/build-system.jam:389: in load-configuration-files from module build-system
/home/janito/boost/tools/build/src/build-system.jam:524: in load from module build-system
/home/janito/boost/tools/build/src/kernel/modules.jam:295: in import from module modules
/home/janito/boost/tools/build/src/kernel/bootstrap.jam:139: in boost-build from module
/home/janito/boost/boost-build.jam:17: in module scope from module
At least the solution was simply to remove the ~/user-config.jam file.
Posting it as an answer so that it can be useful in the future if someone runs into the same situation.

Error in linking fftw libraries for pyFFTW installation

I tried to install pyFFTW 0.9.2 to OSX mavericks, but I encounter the following errors:
/usr/bin/clang -bundle -undefined dynamic_lookup
-L//anaconda/lib -arch x86_64 -arch x86_64
build/temp.macosx-10.5-x86_64-2.7/anaconda/lib/python2.7/site-packages/pyFFTW-master/pyfftw/pyfftw.o
-L//anaconda/lib -lfftw3 -lfftw3f -lfftw3l -lfftw3_threads -lfftw3f_threads -lfftw3l_threads
-o build/lib.macosx-10.5-x86_64-2.7/pyfftw/pyfftw.so
ld: library not found for -lfftw3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As mentioned in pyFFTW installation -> cannot find -lfftw3_threads, I tried to compile and install fftw 3.3.4 for three times. But it is not working for me.
How I did was:
./configure --enable-float --enable-share => make => make install
./configure --enable-long-double --enable-share => make => make install
./configure --enable-threads --enable-share => make => make install
then I run python (2.7) setup files in pyFFTW folder, and I get the error above.
I appreciate your help.
I had the same issue on OSX 10.9.4 Maverick.
Try this:
download FFTW 3.3.4 than open a terminal window and go in the extracted FFTW directory and run these commands:
$ ./configure --enable-long-double --enable-threads
$ make
$ sudo make install
$ ./configure --enable-float --enable-threads
$ make
$ sudo make install
Than install pyFFTW using pip as suggested:
$ sudo pip install pyfftw
I'm using MacOX 10.11.4 and Python 3.5.1 installed through conda and the above answer didn't work for me.
I would still get this error:
ld: library not found for -lfftw3l
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pyfftw
or:
ld: library not found for -lfftw3l_threads
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pyfftw
What did work for me was a slight variation on what I found here:
First install long-double libraries
comp:fftw-3.3.4 user$ ./configure --enable-threads --enable-shared --disable-fortran --enable-long-double CFLAGS="-O3 -fno-common -fomit-frame-pointer -fstrict-aliasing"
comp:fftw-3.3.4 user$ make
comp:fftw-3.3.4 user$ sudo make install
Then install float and double libraries
comp:fftw-3.3.4 user$ ./configure --enable-threads --enable-shared --disable-fortran --enable-sse2 --enable-float CFLAGS="-O3 -fno-common -fomit-frame-pointer -fstrict-aliasing"
comp:fftw-3.3.4 user$ make
comp:fftw-3.3.4 user$ sudo make install
comp:fftw-3.3.4 user$ ./configure --enable-threads --enable-shared --disable-fortran --enable-sse2 CFLAGS="-O3 -fno-common -fomit-frame-pointer -fstrict-aliasing"
comp:fftw-3.3.4 user$ make
comp:fftw-3.3.4 user$ sudo make install
Then install pyfftw
comp:fftw-3.3.4 user$ sudo -H pip install pyfftw
I don't think the --disable-fortran and --enable-sse2 flags are necessary and I'm not sure sudo is necessary for pip but this is what worked for me.
Note that your /usr/local/lib folder should contain the following files when you're done:
libfftw3.3.dylib
libfftw3.a
libfftw3.dylib
libfftw3.la
libfftw3_threads.3.dylib
libfftw3_threads.a
libfftw3_threads.dylib
libfftw3_threads.la
libfftw3f.3.dylib
libfftw3f.a
libfftw3f.dylib
libfftw3f.la
libfftw3f_threads.3.dylib
libfftw3f_threads.a
libfftw3f_threads.dylib
libfftw3f_threads.la
libfftw3l.3.dylib
libfftw3l.a
libfftw3l.dylib
libfftw3l.la
libfftw3l_threads.3.dylib
libfftw3l_threads.a
libfftw3l_threads.dylib
libfftw3l_threads.la

Compile boost C++11 clang mac cannot find cstddef

I cannot compile boost with clang 3.1 on Mac os x 10.8.2.
This is what I did:
./bootstrap.sh --with-toolset=clang
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
I also tried without chrono, test, wave and signals.
I tried a user-config.jam with
using clang-darwin
This is the error I have for almost every file:
/boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found
It is kind of similar to How to compile/link Boost with clang++/libc++?
Thank you :-)
Update:
I do have the latest Xcode 4.5.2 with the command line tools installed.
Here is part of the console output:
Kikohs:trunk kikohs$ ./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
Performing configuration checks
- 32-bit : no
- 64-bit : yes
- x86 : yes
- has_icu builds : no
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- gcc visibility : yes
- long double support : no
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
Building the Boost C++ Libraries.
- iconv (libc) : no
- iconv (separate) : yes
- icu : no
- icu (lib64) : no
Component configuration:
- atomic : building
- chrono : building
- context : building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- math : building
- mpi : building
- program_options : building
- python : building
- random : building
- regex : building
- serialization : building
- signals : building
- system : building
- test : building
- thread : building
- timer : building
- wave : building
...patience...
...patience...
...patience...
...patience...
...found 8672 targets...
...updating 1127 targets...
common.mkdir bin.v2/libs/atomic
common.mkdir bin.v2/libs/atomic/build
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug
clang-darwin.compile.c++ bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o
In file included from libs/atomic/src/lockpool.cpp:1:
./boost/atomic.hpp:10:10: fatal error: 'cstddef' file not found
#include <cstddef>
^
1 error generated.
"clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_DYN_LINK=1 -DBOOST_ATOMIC_SOURCE -I"." -c -o "bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o" "libs/atomic/src/lockpool.cpp"
It looks like you forgot to install the libc++ headers alongside clang.
If you don't want to mess with installing the headers, try the version of clang distributed by Apple as part of the Command Line Tools package; it's been through more testing, and it's already set up properly.
I finally fixed my problem after many hours.
Homebrew was messing with my path and for some reason my clang could not find the libc++ headers.
There is a bug is boost 1.52.
See Boost numeric limits bug
I had to edit the file :
boost/config/stdlib/libcpp.hpp
and patch it:
#if _LIBCPP_VERSION < 1002
# define BOOST_NO_CXX11_NUMERIC_LIMITS
#endif
Now boost is building properly ...
For Ubuntu 16.04, I'm able to build boost with c++11 using gcc:
cd /home/user/install/boost/boost_1_54/
./bootstrap.sh --with-toolset=gcc
./b2 toolset=gcc cxxflags="-std=c++11 -I/usr/include/c++/5/ -I/usr/include/x86_64-linux-gnu/c++/5/"
mkdir ../2
./b2 install --prefix=../2/
The command for building my program:
g++ -std=c++11 -O2 fprint.cpp -o fprint -I/home/user/install/boost/2/include/ -L/home/user/install/boost/2/lib/ -lboost_regex -lboost_program_options
Before that the command was:
g++ -std=c++11 fprint.cpp -o fprint -lboost_regex -lboost_program_options
, but this old command (that worked before well with older OS and boost/etc) doesn't work anymore saying errors
"
undefined reference to boost::re_detail_106501
"
(said by /tmp/cc0Zn8lo.o: In function `bool boost::regex_search...)
((also if I don't use "-I/usr/include/c++/5/ -I/usr/include/x86_64-linux-gnu/c++/5/" for ./b2, then the error is "cannot find cstddef" during building boost, so exactly the same like the subject of this ticket))

Cross compiling boost for m68k using bjam

Using the docs, I run:
$ echo "using gcc : m68k : /opt/freescale/usr/local/gcc-4.2.125-eglibc-2.5.125/m68k-linux/bin/m68k-linux-gnu-g++ ;" > tools/build/v2/user-config.jam
$ ./bootstrap.sh
$ ./bjam -d2 --toolset=gcc-m68k '-sBUILD=release static multi/single' link=static --prefix=/home/damann/coldfire/boost --layout=system --with-filesystem --with-system --with-thread --with-serialization --with-date_time install
Which gives the following errors:
error: toolset gcc initialization:
error: version 'm68k' requested but 'g++-m68k' not found and version '4.4.3' of default 'g++' does not match
error: initialized from
/home/damann/boost_1_48_0/tools/build/v2/build/toolset.jam:38: in toolset.using from module toolset
/home/damann/boost_1_48_0/tools/build/v2/build-system.jam:481: in process-explicit-toolset-requests from module build-system
/home/damann/boost_1_48_0/tools/build/v2/build-system.jam:562: in load from module build-system
/home/damann/boost_1_48_0/tools/build/v2/kernel/modules.jam:283: in import from module modules
/home/damann/boost_1_48_0/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
/home/damann/boost_1_48_0/boost-build.jam:17: in module scope from module
It seems that the user-config is being ignored, although it is read (see it during --debug-configuration)
Discovered that (at least on Linux) bjam also looks for a user-config.jam in the user's homedir - and I had one (that I had forgotten from an earlier build) - so that one was overriding my efforts.