I am trying to compile a C++/OpenCV project for Windows from my GNU/Linux machine (64 bits, Debian Jessie), using cmake. My compiler is mingw, thus I am launching cmake with the following toolchain:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER i586-mingw32-windres)
SET(CUDA_TOOLKIT_ROOT_DIR /usr/bin/nvcc)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-mingw32)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
But cmake return the following error:
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.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 -- broken
CMake Error at /usr/share/cmake-3.0/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/x86_64-w64-mingw32-gcc" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: /data/These/1_A/programmes/remanence/online_version_win32/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec3184109505/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3184109505.dir/build.make
CMakeFiles/cmTryCompileExec3184109505.dir/build
make[1]: Entering directory
'/data/These/1_A/programmes/remanence/online_version_win32/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/data/These/1_A/programmes/remanence/online_version_win32/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec3184109505.dir/testCCompiler.c.o
/usr/bin/x86_64-w64-mingw32-gcc -o
CMakeFiles/cmTryCompileExec3184109505.dir/testCCompiler.c.o -c
/data/These/1_A/programmes/remanence/online_version_win32/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTryCompileExec3184109505
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec3184109505.dir/link.txt --verbose=1
/usr/bin/x86_64-w64-mingw32-gcc
CMakeFiles/cmTryCompileExec3184109505.dir/testCCompiler.c.o -o
cmTryCompileExec3184109505 -rdynamic
x86_64-w64-mingw32-gcc: erreur: unrecognized command line option
‘-rdynamic’
CMakeFiles/cmTryCompileExec3184109505.dir/build.make:88: recipe for target
'cmTryCompileExec3184109505' failed
make[1]: Leaving directory
'/data/These/1_A/programmes/remanence/online_version_win32/CMakeFiles/CMakeTmp'
make[1]: *** [cmTryCompileExec3184109505] Error 1
Makefile:118: recipe for target 'cmTryCompileExec3184109505/fast' failed
make: *** [cmTryCompileExec3184109505/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
But I do not understand why... It seems that there is a problem with the C compiler but I really do not understand how to solve it...
Thank you very much in advance if you have any idea!
Tom
*********EDIT******* Dear Florian,
Thank you for your help!
I tried to use the toolchain you linked but I get the following error:
CUDA_TOOLKIT_ROOT_DIR not found or specified
CMake Error at /usr/share/cmake-3.0/Modules/FindCUDA.cmake:605 (if):
if given arguments:
"CUDA_VERSION" "VERSION_GREATER" "5.0" "AND" "CMAKE_CROSSCOMPILING" "AND" "MATCHES" "arm" "AND" "EXISTS" "CUDA_TOOLKIT_ROOT_DIR-NOTFOUND/targets/armv7-linux-gnueabihf"
Unknown arguments specified
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
-- Configuring incomplete, errors occurred!
And here the CMakeOutput.log
It seems that CMake does not find properly CUDA, but I do not understand why because it works well when I am compiling for GNU/Linux...