Compile boost C++11 clang mac cannot find cstddef - c++

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

Related

Why installed libtorrent shows Import Error?

I have built libtorrent with boost with this commands in the boost root folder :
bootstrap.bat
b2 --hash cxxstd=14 release
and after I have added BOOST_ROOT and BOOST_BUILD_PATH to PATH variable.
I also have downloaded OpenSSL and build it then have copied to Visual studio 15 2017 compiler include and libs folder repectively.
Next in the libtorrent root folder I have run this commands:
b2 variant=release link=shared
b2 install --prefix=build
The build was successful and libtorrent c++ library has created.
and after that I have run these commands :
py setup.py build
py setup.py install
They executed with no errors and libtorrent installed in my python
libs/site-packages folder. But when I import it this error shows:
Python Import Error
[]
What build steps might I have done wrong?
Os : Windows 10 x64
Python : 3.9.5 x64
Libtorrent : 2.0.5
Boost : 1.78.0
I have followed from the libtorrent docs :
https://libtorrent.org/building.html
and
https://www.libtorrent.org/python_binding.html
What did I do ?
Basically following: https://github.com/arvidn/libtorrent/blob/master/docs/building.rst#downloading-and-building
Unzipping boost_1_78_0.zip into D:\boost_1_78_0, and running:
set BOOST_ROOT=D:\boost_1_78_0
set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build
(cd %BOOST_ROOT% && .\bootstrap.bat)
echo using msvc ; >>%HOMEDRIVE%%HOMEPATH%\user-config.jam
%BOOST_ROOT%\b2.exe --hash release
After this i got:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
D:\boost_1_78_0
The following directory should be added to linker library paths:
D:\boost_1_78_0\stage\lib
I think this is where i started to fail, I did not read this the first time, and now I am asking meself where/how should the "compiler include paths" and "linker library paths" be set .?
When trying to compile libtorrent, using the command-line you provided (b2 msvc-14.2 variant=release link=static runtime-link=static debug-symbols=on), i got:
CXXFLAGS =
LDFLAGS =
OS = NT
building boost from source directory: D:/boost_1_78_0
Performing configuration checks
- default address-model : 64-bit (cached) [1]
- default architecture : x86 (cached) [1]
[1] msvc-14.2
...patience...
...patience...
...patience...
...found 3888 targets...
...updating 78 targets...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj
hasher.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
call "bin\standalone\msvc\msvc-14.2\msvc-setup.bat" >nul
cl /Zm800 -nologo "src\hasher.cpp" -c -Fo"bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj" -TP /bigobj /wd4251 /wd4268 /wd4275 /wd4373 /wd4503 /wd4675 /EHs /std:c++14 /GR /Zc:throwingNew /O2 /Z7 /Ob2 /W4 /MT /Zc:forScope /Zc:wchar_t /Zc:inline /Gw /favor:blend -DBOOST_ALL_NO_LIB -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_DEPRECATED -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -DOPENSSL_NO_SSL2 -DTORRENT_BUILDING_LIBRARY -DTORRENT_SSL_PEERS -DTORRENT_USE_I2P=1 -DTORRENT_USE_LIBCRYPTO -DTORRENT_USE_OPENSSL -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_FILE_OFFSET_BITS=64 -D_SCL_SECURE_NO_DEPRECATE -D_WIN32 -D_WIN32_WINNT=0x0600 -D__USE_W32_SOCKETS "-ID:\boost_1_78_0" "-Ideps\try_signal" "-Iinclude" "-Iinclude\libtorrent"
...failed compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\merkle.obj
merkle.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
..... (rest of logging removed)
I found the answer.
While building libtorrent python binding 2 factors are important:
1- openSSL version
2- linking type
python comes with openssl v.1.1 (or similar based on python version) , if building python binding with openssl v.1.1 (which is the latest version while I am writing) one dependency solved otherwise, if using openssl v.3 for building 2 dependency must add to python which they are:
// 32 or 64 bits library based on openssl build
libssl-3-x64.dll
libcrypto-3-x64.dll
2 ) in the time of building python binding 2 commands can be use:
a ) simple with default parameters :
py setup.py build
py setup.py install
In this case in default libtorrent and boost-python linking static.
b ) complex one with more control (I think) :
py setup.py build_ext --b2-args="VARS" install
In the VARS place we can write boost build options but these are the one we want:
libtorrent-link=TYPE boost-link= TYPE
TYPE can be static or shared but anyone that sets shared , it becomes dependency. two files which is in need are :
// 32 and 64 bits file may have different name
// files can have different names but they are similar to below
torrent-rastarbar.dll
boost_python(PYTHON-VERSION)(SOME-INFO).dll
boost python can be find in the boost root directory in the stage/lib .
pleae note that you must build boost and libtorrent SHARED for this solution.
Conclusion :
as mentioned above these dependency must add to based on the build setting you did:
1 - OpenSSL libraries
2 - Boost python
3 - libtorrent libraries
There is an optional file that mentioned in some forums and discussion msvcr90.dll which does not effect on my project but good to point.
Put those files to a directory which can be find by python interpreter or put in project your folder and add this piece of code before imporing libtorrent :
import os
current_path = os.path.abspath(".")
# do not pass relative path like ".", pass full path
os.add_dll_directory(current_path)
Sorry for any poor english. :)

Boost cross compilation with custom Yocto SDK fails with "No such file or directory" errors

I've been given a custom Yocto SDK so as to build a c++ app I've created and the third party libraries that the app depends on.
I've installed the SDK on a VM Ubuntu 16.04.
The first library I needed to build was boost. I use version. 1.64.
I follow the same steps I follow each time to build boost either on a Yocto SDK or a default arm compiler.
$ . /opt/environment-setup-poky-linux-gnueabi
$ ./bootstrap.sh --with-libraries=filesystem,iostreams,program_options,regex,system --prefix=/home/user/Libs
$ nano ~/user-config.jam where I place the following commands
$ using gcc : arm : /opt/sysroots/x86_64-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot= /opt/sysroots/arm-poky-linux-gnueabi ;
$ ./b2 install toolset=gcc-arm link=shared threading=multi
However I always get the following error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs.h:55,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/features.h:452,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/os_defines.h:39,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/c++config.h:508,
from /opt/sysroots/amr-poky-linux-gnueabi/usr/include/c++/8.2.0/cstddef:49,
from ./boost/config/compiler/gcc.hpp:165,
from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
/opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
# include <gnu/stubs-soft.h>
^~~~~~~~~~~~~~~~~~
I assume that the sysroot is not found correctly.
When I tried with a user-config.jam that does not contain --sysroot variable I get the error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
./boost/config/compiler/gcc.hpp:165:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
The CC variable on the environment setup contains the follwoing:
export CC="arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
Is there something I can do to bypass these errors or the SDK is faulty and needs rebuilt ?
Thanks in advance

Build and install Boost 1.60 in 32 bit on a 64 bit Mac OS X El Capitan

I have an application that use the 32 bit boost library( 1.48 ). The 1.48 version of boost was pre built on 32 bit platform and uses older C++ standards.
For example file libboost_wserialization.dylib gives
libboost_wserialization.dylib: Mach-O universal binary with 2 architectures
libboost_wserialization.dylib (for architecture i386): Mach-O dynamically linked shared library i386
libboost_wserialization.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
The requirements have changed and i want to link/use the boost 1.60 with C++ 11 and 32 bit.
I have downloaded the 1.60 boost and modified the bootstrap.sh to include application specific lib and include directories.
I am running the following command
./b2 cxxflags="-std=c++0x -stdlib=libc++" linkflags="-stdlib=libc++" address-model=32 architecture=x86 install
I get the following error
error: unknown target CPU 'i686' for all the files.
If i install the default then I don get the 32 bit version of the boost libraries and application fails to link.
How do i get rid of this error ?. The machine that i am building boost on is Mac OS X El capitan 64 bit.
The entire error is
"clang++" -x c++ -std=c++0x -stdlib=libc++ -O3 -O3 -Wno-inline -Wall -march=i686 -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/atanh.o" "libs/math/build/../src/tr1/atanh.cpp"
...failed clang-darwin.compile.c++ bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/atanh.o...
clang-darwin.compile.c++ bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/cbrt.o
error: unknown target CPU 'i686'
Try with address-model=64.
More info: http://www.boost.org/build/doc/html/bbv2/reference/tools.html#bbv2.reference.tools.compiler.darwin

Compiling Boost 1.54 XCode5 for device - fatal error: error in backend: symbol '___umodsi3' can not be undefined in a subtraction expression

I have been able to successfully compile boost 1.54 for the iOS 7.0 simulator using XCode 5, but when trying to compile for device getting this strange clang failure:
darwin.compile.c++ bin.v2/libs/atomic/build/darwin-7.0~iphone/release/architecture-arm/link-static/macosx-version-iphone-7.0/target-os-iphone/threading-multi/lockpool.o
fatal error: error in backend: symbol '___umodsi3' can not be undefined in a subtraction expression
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: arm-apple-darwin12.5.0
Thread model: posix
Here are my user-config.jam settings:
using clang : : : <cxxflags>"-std=c++11 -stdlib=libc++" <linkflags>"-stdlib=libc++" ;
using darwin : 7.0~iphone
: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
: <striper> <root>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
<compileflags>"-arch armv7"
<compileflags>"-arch armv7s"
<compileflags>-mthumb
<compileflags>-fvisibility=hidden
<compileflags>-fvisibility-inlines-hidden
<compileflags>-std=c++11
<compileflags>-stdlib=libc++
<compileflags>-miphoneos-version-min=5.1
<compileflags>-D_LITTLE_ENDIAN
<compileflags>"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk"
: <architecture>arm <target-os>iphone
;
using darwin : 7.0~iphonesim
: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
: <striper> <root>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
<compileflags>"-arch i386"
<compileflags>-fvisibility=hidden
<compileflags>-fvisibility-inlines-hidden
<compileflags>-std=c++11
<compileflags>-stdlib=libc++
<compileflags>-miphoneos-version-min=5.1
<compileflags>-D_LITTLE_ENDIAN
<compileflags>"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk"
: <architecture>x86 <target-os>iphone
;
Detailed steps to reproduce:
1. Download and extract the latest sources for boost 1.54
2. Create a user-config.jam in user's home directory (w text above).
3. Run ./bootstrap.sh in the boost directory
4. Run
./b2 toolset=darwin-7.0~iphone architecture=arm target-os=iphone macosx-version=iphone-7.0 threading=multi linkflags=-stdlib=libc++ define=_LITTLE_ENDIAN link=static install
This will result in the error above.
For comparison, when compiling for the simulator with the following line:
./b2 toolset=darwin-7.0~iphonesim architecture=x86 target-os=iphone macosx-version=iphone-7.0 threading=multi linkflags=-stdlib=libc++ link=static install
This works fine and correctly generates the boost libraries for use with the simulator.
Would anyone have a suggestion as to what could be causing this? Is it a clang compiler problem or am I using the device compile incorrectly? I have been able to compile for device with XCode 4.x with no problem previously...
Thanks!
Daniel
I may have found the answer. Use
<compileflags>-mno-thumb
instead of:
<compileflags>-mthumb
Works for me now.

Cross-compiling boost for Windows on Linux

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")