Orphis / boost-cmake

Easy Boost integration in CMake projects
Other
399 stars 150 forks source link

Cross compilation issue from linux to windows #99

Open simchanu29 opened 3 years ago

simchanu29 commented 3 years ago

I'm trying to cross-compile Boost to Windows using this project.

OS : Ubuntu 20

The cross compiler has been installed with :

sudo apt install mingw-w64

My cross compilation toolchain :

set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

# cross compilers to use for C, C++ and Fortran
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

# target environment on the build host system
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

# modify default behavior of FIND_XXX() commands
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

The relevant part of my CMakeLists.txt :

# Find boost
add_subdirectory(libs/boost-cmake)

set(Boost_LIBRARIES
    PUBLIC Boost::filesystem
    PUBLIC Boost::system
    PUBLIC Boost::coroutine
)

add_executable(myexec src/main.cpp ${myexec_srcs})
target_link_libraries(myexec ${myexec_libs} ${Boost_LIBRARIES})

Cmake seems to run properly :

-- Fetching Boost
-- Fetching Boost - done
-- Boost found: 1.71.0 /mnt/34B6EBFAB6EBBB0E/Workspace_CCpp/SBPL_cpp/build/_deps/boost-src
-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) 
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- The following ICU libraries were not found:
--   uc (required)
--   dt (required)
--   i18n (required)
-- Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY _ICU_REQUIRED_LIBS_FOUND) 
-- Configuring done
-- Generating done

I don't have BZIP2 ICU or ZLIB since i'm using the cross compilation chain so that's ok.

But I get the following error :

[  4%] Built target Boost_chrono
[  8%] Built target Boost_thread
[  8%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 13%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 13%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 13%] Linking CXX static library libboost_context.a
/usr/bin/x86_64-w64-mingw32-ar: CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj: Aucun fichier ou dossier de ce type
make[2]: *** [project/libs/boost-cmake/CMakeFiles/Boost_context.dir/build.make:107 : sbpl_cpp/libs/boost-cmake/libboost_context.a] Erreur 1
make[1]: *** [CMakeFiles/Makefile2:672 : project/libs/boost-cmake/CMakeFiles/Boost_context.dir/all] Erreur 2
make: *** [Makefile:84 : all] Erreur 2

It seems it fails in the compilation of coroutine dependencies. It's as if there was somewhere a -c flag to prevent linking but I can't find it. Any input on this issue is welcome.


To provide some context :

Orphis commented 3 years ago

Can you show the output of make VERBOSE=1? It should show us what command line was used to build the ASM files.

simchanu29 commented 3 years ago

Here is the whole output.

For your information I changed the project path to /home/user/Myproject and the subdirectory inside to project, so boost-cmake path is : /home/user/MyProject/project/libs/boost-cmake.

$ make VERBOSE=1
/usr/bin/cmake -S/home/user/MyProject -B/home/user/MyProject/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/user/MyProject/build/CMakeFiles /home/user/MyProject/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1] : on entre dans le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/depend
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
cd /home/user/MyProject/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/MyProject /home/user/MyProject/libs/boost-cmake /home/user/MyProject/build /home/user/MyProject/build/project/libs/boost-cmake /home/user/MyProject/build/project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/DependInfo.cmake --color=
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/build
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
make[2]: rien à faire pour « project/libs/boost-cmake/CMakeFiles/Boost_filesystem.dir/build ».
make[2] : on quitte le répertoire « /home/user/MyProject/build »
[ 17%] Built target Boost_filesystem
make -f project/libs/boost-cmake/CMakeFiles/Boost_system.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_system.dir/depend
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
cd /home/user/MyProject/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/MyProject /home/user/MyProject/libs/boost-cmake /home/user/MyProject/build /home/user/MyProject/build/project/libs/boost-cmake /home/user/MyProject/build/project/libs/boost-cmake/CMakeFiles/Boost_system.dir/DependInfo.cmake --color=
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_system.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_system.dir/build
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
make[2]: rien à faire pour « project/libs/boost-cmake/CMakeFiles/Boost_system.dir/build ».
make[2] : on quitte le répertoire « /home/user/MyProject/build »
[ 23%] Built target Boost_system
make -f project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/depend
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
cd /home/user/MyProject/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/MyProject /home/user/MyProject/libs/boost-cmake /home/user/MyProject/build /home/user/MyProject/build/project/libs/boost-cmake /home/user/MyProject/build/project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/DependInfo.cmake --color=
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/build
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
make[2]: rien à faire pour « project/libs/boost-cmake/CMakeFiles/Boost_chrono.dir/build ».
make[2] : on quitte le répertoire « /home/user/MyProject/build »
[ 29%] Built target Boost_chrono
make -f project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/depend
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
cd /home/user/MyProject/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/MyProject /home/user/MyProject/libs/boost-cmake /home/user/MyProject/build /home/user/MyProject/build/project/libs/boost-cmake /home/user/MyProject/build/project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/DependInfo.cmake --color=
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/build
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
make[2]: rien à faire pour « project/libs/boost-cmake/CMakeFiles/Boost_thread.dir/build ».
make[2] : on quitte le répertoire « /home/user/MyProject/build »
[ 35%] Built target Boost_thread
make -f project/libs/boost-cmake/CMakeFiles/Boost_context.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_context.dir/depend
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
cd /home/user/MyProject/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/MyProject /home/user/MyProject/libs/boost-cmake /home/user/MyProject/build /home/user/MyProject/build/project/libs/boost-cmake /home/user/MyProject/build/project/libs/boost-cmake/CMakeFiles/Boost_context.dir/DependInfo.cmake --color=
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make -f project/libs/boost-cmake/CMakeFiles/Boost_context.dir/build.make project/libs/boost-cmake/CMakeFiles/Boost_context.dir/build
make[2] : on entre dans le répertoire « /home/user/MyProject/build »
[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 41%] Linking CXX static library libboost_context.a
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/cmake -P CMakeFiles/Boost_context.dir/cmake_clean_target.cmake
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/cmake -E cmake_link_script CMakeFiles/Boost_context.dir/link.txt --verbose=1
/usr/bin/x86_64-w64-mingw32-ar qc libboost_context.a  CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/windows/stack_traits.cpp.obj
/usr/bin/x86_64-w64-mingw32-ar: CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj: Aucun fichier ou dossier de ce type
make[2]: *** [project/libs/boost-cmake/CMakeFiles/Boost_context.dir/build.make:107 : libs/boost-cmake/libboost_context.a] Erreur 1
make[2] : on quitte le répertoire « /home/user/MyProject/build »
make[1]: *** [CMakeFiles/Makefile2:567 : project/libs/boost-cmake/CMakeFiles/Boost_context.dir/all] Erreur 2
make[1] : on quitte le répertoire « /home/user/MyProject/build »
make: *** [Makefile:84 : all] Erreur 2

[EDIT : I just realized the logs are in french. I you need I can change my system language to generate them in english]

It seems the command used is :

/usr/bin/x86_64-w64-mingw32-ar qc libboost_context.a  CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/windows/stack_traits.cpp.obj

I checked, the asm folder is empty image

So my guess is that asm files were never generated because of these lines :

[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/make_x86_64_ms_pe_gas.asm: linker input file unused because linking not done
[ 41%] Building ASM object project/libs/boost-cmake/CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj
cd /home/user/MyProject/build/project/libs/boost-cmake && /usr/bin/x86_64-w64-mingw32-gcc -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_EXPORT -DBOOST_CONTEXT_SOURCE=1 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -isystem /home/user/MyProject/build/_deps/boost-src  -g   -Wall -Wextra -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare -g -w -o CMakeFiles/Boost_context.dir/__/__/__/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm.obj -c /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm
x86_64-w64-mingw32-gcc: warning: /home/user/MyProject/build/_deps/boost-src/libs/context/src/asm/ontop_x86_64_ms_pe_gas.asm: linker input file unused because linking not done

Maybe because of the -c option ? (https://stackoverflow.com/questions/2395158/linker-error-linker-input-file-unused-because-linking-not-done-undefined-ref) image

However, other dependencies (thread, chrono) seems to build correctly with this option but they only build .cpp files and no .asm files. I can provide a full build log of Boost_context if necessary (output of make clean && make Boost_context VERBOSE=1).