Hello, I'm trying to cross compile a project on Arch Linux using MinGW for Windows.
I've installed a lot of libraries from their AUR into /usr/x86_64-w64- mingw32. This seems okay as CMake finds every library needed. My example project consists of: cmake_minimum_required(VERSION 3.5) project(test) find_package(PNG REQUIRED) add_executable(main main.cpp) target_link_libraries(main PNG::PNG) The main.cpp only contains an #include <cstdlib> statement. The toolchain file contains: set (CMAKE_SYSTEM_NAME Windows) set (CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) set (CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set (QT_BINARY_DIR /usr/x86_64-w64-mingw32/bin /usr/bin) set (QT_INCLUDE_DIRS_NO_SYSTEM ON) set (CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) set (CMAKE_MC_COMPILER x86_64-w64-mingw32-windmc) set (Boost_THREADAPI win32) set (CMAKE_Fortran_COMPILER x86_64-w64-mingw32-gfortran) set (CMAKE_AR:FILEPATH x86_64-w64-mingw32-ar) set (CMAKE_RANLIB:FILEPATH x86_64-w64-mingw32-ranlib) Then, running CMake with that toolchain produce: $ cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-x86_64-w64- mingw32.cmake .. -- The C compiler identification is GNU 6.1.1 -- The CXX compiler identification is GNU 6.1.1 -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found ZLIB: /usr/x86_64-w64-mingw32/lib/libz.dll.a (found version "1.2.8") -- Found PNG: /usr/x86_64-w64-mingw32/lib/libpng.dll.a (found version "1.6.24") -- Configuring done -- Generating done -- Build files have been written to: /tmp/test/build So as you can see, the libraries are correctly found. However, compile fails with: $ make Scanning dependencies of target main [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.obj In file included from /tmp/test/main.cpp:1:0: /usr/x86_64-w64-mingw32/include/c++/6.1.1/cstdlib:75:25: fatal error: stdlib.h: No such file or directory #include_next <stdlib.h> ^ compilation terminated. The includes directories specified in the CMakeFiles/main.dir/includes_CSS.rsp seems to be the culprit: $ cat CMakeFiles/main.dir/includes_CXX.rsp -isystem /usr/x86_64-w64-mingw32/include Removing that option from the file ends with a successful build. I don't understand why it does not work with that because stdlib.h can be found as /usr/x86_64-w64-mingw32/include/stdilb.h. Do you have any clue? Regards, -- David Demelier -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake