Skip to content

Cross compilation issue from linux to windows #99

@simchanu29

Description

@simchanu29

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 :

  • I already tried to cross compile boost from linux with no success. So i decided to try this repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions