cross-compilation: building boost on linux targetting osx
Hi, I am trying to cross-build boost on linux targetting osx. I am using a cross compiler based on the linux clang 3.8.1 (osxcross). You can find below the process I use to build boost. My problem is that apparently b2 cannot find iconv, zlib and bzip2. Also apprently it says that clang does not support C++11 features (which is not true): - Boost.Config Feature Check: cxx11_auto_declarations : no - Boost.Config Feature Check: cxx11_constexpr : no - Boost.Config Feature Check: cxx11_defaulted_functions : no - Boost.Config Feature Check: cxx11_final : no - Boost.Config Feature Check: cxx11_hdr_mutex : no - Boost.Config Feature Check: cxx11_hdr_tuple : no - Boost.Config Feature Check: cxx11_lambdas : no - Boost.Config Feature Check: cxx11_noexcept : no - Boost.Config Feature Check: cxx11_nullptr : no - Boost.Config Feature Check: cxx11_rvalue_references : no - Boost.Config Feature Check: cxx11_template_aliases : no - Boost.Config Feature Check: cxx11_thread_local : no - Boost.Config Feature Check: cxx11_variadic_templates : no - zlib : no - bzip2 : no - iconv (libc) : no - iconv (separate) : no - Boost.Locale needs either iconv or ICU library to be built. I identified potential issues: 1. I give toolset clang to bootstrap.sh which sets the toolset to clang in project-config.jam but clang-linux is used: common.mkdir bin.v2/libs/system/build/clang-linux-3.8.1/release Should it be clang-darwin instead? However, if I set it myself to clang-darwin with bootstrap.sh, it says that clang-darwin toolset does not exist. By the way, there is nothing about clang in getting started: http://www.boost.org/doc/libs/1_63_0/more/getting_started/unix-variants.html 2. when looking for the iconv library (same issue with zlib and bzip2), there are unknown linker options (--start-group or -R) and the iconv library path I gave to b2 is not given to the compiler/linker. Here is part of the output in config.log: clang-linux.compile.c++.without-pth bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_obj.o "x86_64-apple-darwin13-clang++-libc++" -c -x c++ -std=c++14 -O2 -DNDEBUG -O0 -g -fno-inline -Wall -g -fPIC -m64 -DBOOST_ALL_NO_LIB=1 -DBOOST_LOG_WITHOUT_EVENT_LOG -DBOOST_THREAD_USE_LIB -I"." -o "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_obj.o" "libs/locale/src/../build/has_iconv.cpp" "x86_64-apple-darwin13-clang++-libc++" -o "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv" -Wl,--start-group "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_obj.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g -m64~ ld: unknown option: --start-group clang-linux.compile.c++.without-pth bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_ext.o "x86_64-apple-darwin13-clang++-libc++" -c -x c++ -std=c++14 -O2 -DNDEBUG -O0 -g -fno-inline -Wall -g -fPIC -m64 -DBOOST_ALL_NO_LIB=1 -DBOOST_LOG_WITHOUT_EVENT_LOG -DBOOST_THREAD_USE_LIB -I"." -I"/softs/osx64-clang-3.8.1/release/iconv/include" -o "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_ext.o" "libs/locale/src/../build/has_iconv.cpp" "x86_64-apple-darwin13-clang++-libc++" -L"/softs/osx64-clang-3.8.1/release/iconv/lib" -Wl,-R -Wl,"/softs/osx64-clang-3.8.1/release/iconv/lib" -Wl,-rpath-link -Wl,"/softs/osx64-clang-3.8.1/release/iconv/lib" -o "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_external_iconv" -Wl,--start-group "bin.v2/libs/locale/build/clang-linux-3.8.1/debug/target-os-darwin/has_iconv_libc_ext.o" -Wl,-Bstatic -Wl,-Bdynamic -liconv -Wl,--end-group -g -m64~ ld: unknown option: -R Any idea? Frédéric Currently, I am using the following commands to build boost: CC="x86_64-apple-darwin13-clang" CFLAGS="-O2 -DNDEBUG" CXX="x86_64-apple-darwin13-clang++-libc++" CXXFLAGS="-O2 -DNDEBUG -std=c++14" CPPFLAGS="-I/softs/osx64-clang-3.8.1/release/iconv/include -I/softs/osx64-clang-3.8.1/release/bzip2/include -I/softs/osx64-clang-3.8.1/release/zlib/include" LDFLAGS="-L/softs/osx64-clang-3.8.1/release/iconv/lib -L/softs/osx64-clang-3.8.1/release/bzip2/lib -L/softs/osx64-clang-3.8.1/release/zlib/lib" AR="x86_64-apple-darwin13-ar" AS="x86_64-apple-darwin13-as" RANLIB="x86_64-apple-darwin13-ranlib" ./bootstrap.sh --without-icu --prefix=/softs/osx64-clang-3.8.1/release/boost --with-toolset=clang then I write a user-config.jam: using clang : : x86_64-apple-darwin13-clang++-libc++ : <cxxflags>-std=c++14 <cxxflags>-O2 <cxxflags>-DNDEBUG <archiver>x86_64-apple-darwin13-ar <ranlib>x86_64-apple-darwin13-ranlib ; and run b2: CC="x86_64-apple-darwin13-clang" CFLAGS="-O2 -DNDEBUG" CXX="x86_64-apple-darwin13-clang++-libc++" CXXFLAGS="-O2 -DNDEBUG -std=c++14" CPPFLAGS="-I/softs/osx64-clang-3.8.1/release/iconv/include -I/softs/osx64-clang-3.8.1/release/bzip2/include -I/softs/osx64-clang-3.8.1/release/zlib/include" LDFLAGS="-L/softs/osx64-clang-3.8.1/release/iconv/lib -L/softs/osx64-clang-3.8.1/release/bzip2/lib -L/softs/osx64-clang-3.8.1/release/zlib/lib" AR="x86_64-apple-darwin13-ar" AS="x86_64-apple-darwin13-as" RANLIB="x86_64-apple-darwin13-ranlib" ./b2 -d2 -j8 boost.locale.iconv=on boost.locale.icu=off boost.locale.std=off -sICONV_PATH=/softs/osx64-clang-3.8.1/release/iconv -sBZIP2_INCLUDE=/softs/osx64-clang-3.8.1/release/bzip2/include -sBZIP2_LIBPATH=/softs/osx64-clang-3.8.1/release/bzip2/lib -sZLIB_INCLUDE=/softs/osx64-clang-3.8.1/release/zlib/include -sZLIB_LIBPATH=/softs/osx64-clang-3.8.1/release/zlib/lib --layout=system --user-config=user-config.jam --without-mpi --without-python --without-context --without-coroutine link=static threading=multi runtime-link=shared target-os=darwin threadapi=pthread address-model=64 define=BOOST_THREAD_USE_LIB define=BOOST_LOG_WITHOUT_EVENT_LOG variant=release install
"Frédéric Bronvia Boost" wrote:
I am trying to cross-build boost on linux targetting osx. I am using a cross compiler based on the linux clang 3.8.1 (osxcross). ... I identified potential issues:
1. I give toolset clang to bootstrap.sh which sets the toolset to clang in project-config.jam but clang-linux is used: common.mkdir bin.v2/libs/system/build/clang-linux-3.8.1/release
Should it be clang-darwin instead?
bootstrap.sh builds b2 and the set of toolsets used for this is completely different than the one Boost.Build has. It needs to be a host native toolset.
Currently, I am using the following commands to build boost: ... and run b2:
CC="x86_64-apple-darwin13-clang" CFLAGS="-O2 -DNDEBUG" CXX="x86_64-apple-darwin13-clang++-libc++" CXXFLAGS="-O2 -DNDEBUG -std=c++14"
To my knowledge these environment variables aren't used by Boost.Build. Aren't they typically used by make, which isn't involved here? Why not put all the compiler flags in user-config.jam? You can use <linkflags> for the linker flags. Use quotes like this to reduce repetition: <cxxflags>"-x -y -z".
./b2 -d2
This should make b2 print the full command-line of each command. Have you compared that to what you expect?
boost.locale.iconv=on boost.locale.icu=off boost.locale.std=off
I have never seen these before. Where are they described? Regards, Niklas Angare
1. I give toolset clang to bootstrap.sh which sets the toolset to clang in project-config.jam but clang-linux is used: common.mkdir bin.v2/libs/system/build/clang-linux-3.8.1/release
Should it be clang-darwin instead?
bootstrap.sh builds b2 and the set of toolsets used for this is completely different than the one Boost.Build has. It needs to be a host native toolset.
OK, you're right. I now let it to its default and then change the default toolset in project-config.jam to the one I want to use for boost buidling.
Currently, I am using the following commands to build boost:
...
and run b2:
CC="x86_64-apple-darwin13-clang" CFLAGS="-O2 -DNDEBUG" CXX="x86_64-apple-darwin13-clang++-libc++" CXXFLAGS="-O2 -DNDEBUG -std=c++14"
To my knowledge these environment variables aren't used by Boost.Build. Aren't they typically used by make, which isn't involved here?
You are right, not used by boost build but I just use to always do this when I compile libraries because "normal" libraries use ./congiure; make; make install and use these.
Why not put all the compiler flags in user-config.jam? You can use <linkflags> for the linker flags. Use quotes like this to reduce repetition: <cxxflags>"-x -y -z".
done, and this seems to have fixed my issues. The reason I did not do it before was because they are some command lines options for zlib, bzip2 and iconv: -sICONV_PATH=/softs/osx64-clang-3.8.1/release/iconv -sBZIP2_INCLUDE=/softs/osx64-clang-3.8.1/release/bzip2/include -sBZIP2_LIBPATH=/softs/osx64-clang-3.8.1/release/bzip2/lib -sZLIB_INCLUDE=/softs/osx64-clang-3.8.1/release/zlib/include -sZLIB_LIBPATH=/softs/osx64-clang-3.8.1/release/zlib/lib apprently they do not work very well.
./b2 -d2 This should make b2 print the full command-line of each command. Have you compared that to what you expect?
Yes, I have a full log with all commands. The right compiler is used but ar and ranlib are not the right ones. I have to re-run them when it is finished. Instead of linux ar and ranlib, I run {i386,x86_64}-apple-darwin13-{ar,ranlib}. Concerning dependencies, it is in the configure part that it happens and can be found in bin.v2/config.log
boost.locale.iconv=on boost.locale.icu=off boost.locale.std=off
I have never seen these before. Where are they described?
http://www.boost.org/doc/libs/1_63_0/libs/locale/doc/html/building_boost_loc... I have now fixed everything. I found that clang toolsets are broken in case of cross-compilation. I had to manually modifiy them. For example, <archiver> and <ranlib> are not used. plain "ar" and "ranlib" are used. Regards, Frédéric
participants (2)
-
Frédéric Bron
-
Niklas Angare