views:

1175

answers:

2

I am trying to compile my project on Snow Leopard using the same CMakeLists.txt file that I had on Leopard, however the compilation fails with the following error message:

   Linking C executable cmTryCompileExec

  "/Applications/CMake 2.6-4.app/Contents/bin/cmake" -E cmake_link_script
  CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1

  /Developer/usr/bin/gcc -Wl,-search_paths_first -headerpad_max_install_names
  -fPIC CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o cmTryCompileExec


  ld: library not found for -lcrt1.10.5.o

  collect2: ld returned 1 exit status

  make[1]: *** [cmTryCompileExec] Error 1

It seems that the default behavior for cmake is to compile universal binaries on MACOSX, however Snow Leopard no longer supports universal binaries, and hence we get the above error. Is there a way to disable linking to -lcrt1.10.5.o when using cmake on a Mac to generate only Intel binaries?

+2  A: 

It appears that this is a bug with cmake compiling x86_64 binaries despite CMAKE_OSX_ARCHITECTURES being set to i386.

http://public.kitware.com/Bug/view.php?id=9466

As a temporary workaround, I am using

CMAKE_OSX_ARCHITECTURES = i386;ppc

celil
+2  A: 

Another temporary workaround is to pass the following to CMake:

-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32

This tells GCC to compile 32-bit binaries and doesn't require compiling ppc binaries too like the above.

Mike McQuaid