I was trying to cross compile from snow leopard to iphone simulator.
struggled a few days with  "file was built for i386 which is not the
architecture being linked (x86_64)".
and found http://www.itk.org/Bug/view.php?id=9466 bug history.

looks like the same bug popped up in 2.8.2 version.
The error was gone with 2.6.4

Below is the full bug.

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler:
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
-- Check for working C compiler:
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 --
broken
CMake Error at /Applications/CMake
2.8-2.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52
(MESSAGE):
  The C compiler
  "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/eugenekim/Documents/BrainGame/CMakeFiles/CMakeTmp



  Run Build Command:/usr/bin/make "cmTryCompileExec/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
  CMakeFiles/cmTryCompileExec.dir/build

  "/Applications/CMake 2.8-2.app/Contents/bin/cmake" -E
cmake_progress_report
  /Users/eugenekim/Documents/BrainGame/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj

  /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
  
-I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include
  
-I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/opt/iphone-simulator-4.0/include
  
-I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/local/iphone-simulator-4.0/include
  -pipe -no-cpp-precomp
  
--sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
  -miphoneos-version-min=4.0 -o
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj -c
  /Users/eugenekim/Documents/BrainGame/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTryCompileExec

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

  /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj -o cmTryCompileExec
  
-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/lib
  
-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/opt/iphone-simulator-4.0/lib
  
-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/local/iphone-simulator-4.0/lib


  ld: warning: in
  
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/lib/libSystem.dylib,
  file was built for i386 which is not the architecture being linked
(x86_64)

  Undefined symbols:

    "_exit", referenced from:
        start in crt1.10.6.o

  ld: symbol(s) not found

  collect2: ld returned 1 exit status

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

  make: *** [cmTryCompileExec/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!


toolchain file




# Michael Aaron Safyan (michaelsaf...@gmail.com). Copyright (C) 2009-2010.
Simplified BSD License.
SET (CMAKE_SYSTEM_NAME Generic)
SET (CMAKE_SYSTEM_VERSION 1)
SET (CMAKE_SYSTEM_PROCESSOR i686)
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)

SET (SDKVER "4.0")
SET (DEVROOT "/Developer/Platforms/iPhoneSimulator.platform/Developer")
SET (SDKROOT "${DEVROOT}/SDKs/iPhoneSimulator${SDKVER}.sdk")
SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
#SET (CMAKE_OSX_ARCHITECTURES "i386" "x86_64")
SET (CMAKE_OSX_ARCHITECTURES "i386")


SET (CMAKE_C_COMPILER "${DEVROOT}/usr/bin/gcc-4.2")
SET (CMAKE_CXX_COMPILER "${DEVROOT}/usr/bin/g++-4.2")

SET (CMAKE_C_COMPILER "${DEVROOT}/usr/bin/gcc-4.2")
SET (CMAKE_CXX_COMPILER "${DEVROOT}/usr/bin/g++-4.2")

SET (CMAKE_C_FLAGS "-std=c99" "-x objective-c")
SET (CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS} "-DDEBUG=1" "-ggdb")
SET (CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS} "-DNDEBUG=1")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS} "-DNDEBUG=1" "-ggdb")

SET (CMAKE_CXX_FLAGS "-x objective-c++")
SET (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS} "-DDEBUG=1" "-ggdb")
SET (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS} "-DNDEBUG=1")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS} "-DNDEBUG=1" "-ggdb")

#ADD_DEFINITIONS("-arch i386")
#ADD_DEFINITIONS("-arch x86_64")
ADD_DEFINITIONS("-pipe")
ADD_DEFINITIONS("-no-cpp-precomp")
ADD_DEFINITIONS("--sysroot=${SDKROOT}")
ADD_DEFINITIONS("-miphoneos-version-min=${SDKVER}")

INCLUDE_DIRECTORIES(SYSTEM "${SDKROOT}/usr/include")
INCLUDE_DIRECTORIES(SYSTEM
"${SDKROOT}/opt/iphone-simulator-${SDKVER}/include")
INCLUDE_DIRECTORIES(SYSTEM
"${SDKROOT}/usr/local/iphone-simulator-${SDKVER}/include")

LINK_DIRECTORIES("${SDKROOT}/usr/lib")
LINK_DIRECTORIES("${SDKROOT}/opt/iphone-simulator-${SDKVER}/lib")
LINK_DIRECTORIES("${SDKROOT}/usr/local/iphone-simulator-${SDKVER}/lib")

SET (CMAKE_FIND_ROOT_PATH "${SDKROOT}" "/opt/iphone-simulator-${SDKVER}/"
"/usr/local/iphone-simulator-${SDKVER}/")
SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET (iPhone 1)
SET (iPhoneSimulator 1)
SET (iPhoneSimulator_VERSION ${SDKVER})
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to