[CMake] Cross-compilation for windows on Darwin with nighlty build fails

Claus Klein claus.klein at arcormail.de
Thu Jul 12 16:23:04 EDT 2012


I tried with the current nightly cmake binary to cross compile with  
mingw tools on Darwin.

But it fails and I have no right idea what goes wrong.

First, the rc compile was not found:

+ cmake -G 'Unix Makefiles' -DCMAKE_C_COMPILER=i386-mingw32-gcc - 
DCMAKE_CXX_COMPILER=i386-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows-GNU - 
DCMAKE_INSTALL_PREFIX=C:/usr --check-system-vars ..
Also check system files when warning about unused and uninitialized  
variables.
-- The C compiler identification is GNU 3.4.5
-- The CXX compiler identification is GNU 3.4.5
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not  
found.   Please set CMAKE_RC_COMPILER to a valid compiler path or name.
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc
CMake Error at /usr/local/share/cmake-2.8/Modules/ 
CMakeRCInformation.cmake:22 (GET_FILENAME_COMPONENT):
   get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
   /usr/local/share/cmake-2.8/Modules/Platform/Windows-GNU.cmake:60  
(enable_language)
   /usr/local/share/cmake-2.8/Modules/ 
CMakeSystemSpecificInformation.cmake:36 (INCLUDE)
   CMakeLists.txt:2 (PROJECT)


CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc --  
broken
CMake Error at /usr/local/share/cmake-2.8/Modules/ 
CMakeTestCCompiler.cmake:52 (MESSAGE):
   The C compiler "/opt/local/bin/i386-mingw32-gcc" is not able to  
compile a
   simple test program.

-----------------------------------------------------------

Than I defined it and the host binutils are used:

+ cmake -G 'Unix Makefiles' -DCMAKE_C_COMPILER=i386-mingw32-gcc - 
DCMAKE_CXX_COMPILER=i386-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows-GNU - 
DCMAKE_INSTALL_PREFIX=C:/usr -DCMAKE_RC_COMPILER=i386-mingw32-windres  
--check-system-vars ..
Also check system files when warning about unused and uninitialized  
variables.
-- The C compiler identification is GNU 3.4.5
-- The CXX compiler identification is GNU 3.4.5
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc --  
works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/local/bin/i386-mingw32-g++
-- Check for working CXX compiler: /opt/local/bin/i386-mingw32-g++ --  
works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
MINGW
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_RC_COMPILER= i386-mingw32-windres

-- The C compiler identification is GNU 3.4.5
-- The CXX compiler identification is GNU 3.4.5
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc
-- Check for working C compiler: /opt/local/bin/i386-mingw32-gcc --  
works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag -  
no
-- Check for working CXX compiler: /opt/local/bin/i386-mingw32-g++
-- Check for working CXX compiler: /opt/local/bin/i386-mingw32-g++ --  
works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
MINGW
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clausklein/Workspace/cpp/ 
ftplibpp-2.0.2/build
+ exit
claus-kleins-macbook-pro:build clausklein$ !gre
grep -w FILEPATH CMakeCache.txt
CMAKE_AR:FILEPATH=/opt/local/bin/ar
CMAKE_CXX_COMPILER:FILEPATH=/opt/local/bin/i386-mingw32-g++
CMAKE_C_COMPILER:FILEPATH=/opt/local/bin/i386-mingw32-gcc
CMAKE_INSTALL_NAME_TOOL:FILEPATH=/opt/local/bin/install_name_tool
CMAKE_LINKER:FILEPATH=/opt/local/bin/ld
CMAKE_MAKE_PROGRAM:FILEPATH=/opt/local/bin/gmake
CMAKE_NM:FILEPATH=/opt/local/bin/nm
CMAKE_OBJCOPY:FILEPATH=CMAKE_OBJCOPY-NOTFOUND
CMAKE_OBJDUMP:FILEPATH=CMAKE_OBJDUMP-NOTFOUND
CMAKE_RANLIB:FILEPATH=/opt/local/bin/ranlib
CMAKE_RC_COMPILER:FILEPATH=i386-mingw32-windres
CMAKE_STRIP:FILEPATH=/opt/local/bin/strip
CMAKE_XCODE_SELECT:FILEPATH=/usr/bin/xcode-select
claus-kleins-macbook-pro:build clausklein$

------------------------------------------------------

A a third try I defined all binutils too:


cmake -G "Unix Makefiles" \
     -DCMAKE_C_COMPILER=i386-mingw32-gcc -DCMAKE_CXX_COMPILER=i386- 
mingw32-g++ \
     -DCMAKE_SYSTEM_NAME=Windows-GNU -DCMAKE_INSTALL_PREFIX="C:/usr" \
     --check-system-vars \
     -DCMAKE_AR=i386-mingw32-ar \
     -DCMAKE_RANLIB=i386-mingw32-ranlib \
     -DCMAKE_RC_COMPILER=i386-mingw32-windres \
     ..

make

...

Linking CXX static library lib/libftpcpp.a
/opt/local/bin/ranlib: warning for library: lib/libftpcpp.a the table  
of contents is empty (no object file members in the library define  
global symbols)
[ 40%] Built target ftpcpp
Scanning dependencies of target ftpGet
[ 60%] Building CXX object CMakeFiles/ftpGet.dir/ftpGet.cpp.obj
In file included from /Users/clausklein/Workspace/cpp/ftplibpp-2.0.2/ 
ftpGet.cpp:3:
/Users/clausklein/Workspace/cpp/ftplibpp-2.0.2/fetchurl.h:69:2:  
warning: #warning MAXHOSTNAMELEN undefined
/Users/clausklein/Workspace/cpp/ftplibpp-2.0.2/fetchurl.h:73:2:  
warning: #warning MAXLOGNAME undefined
Linking CXX executable bin/ftpGet
/opt/local/lib/gcc/i386-mingw32/3.4.5/../../../../i386-mingw32/bin/ 
ld:lib/libftpcpp.a: file format not recognized; treating as linker  
script
/opt/local/lib/gcc/i386-mingw32/3.4.5/../../../../i386-mingw32/bin/ 
ld:lib/libftpcpp.a:1: syntax error
collect2: ld returned 1 exit status
make[2]: *** [bin/ftpGet] Error 1
make[1]: *** [CMakeFiles/ftpGet.dir/all] Error 2
make: *** [all] Error 2
claus-kleins-macbook-pro:build clausklein$


with same result!

The ranlib and ar from build host is used.

Any idea what I should try or do would help?

Claus




More information about the CMake mailing list