I'm trying to compile code for an ARM processor on an x86-64 Ubuntu machine. I'm using scratchbox, compiling programes with the standard autoconf/configure scripts work fine so the cross compiler works.

When I use Cmake I runinto problems, the following is my arm_cross.cmake file

INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)
SET(CMAKE_AR /scratchbox/compilers/arm-linux-cs2010q1-202/bin/sbox-arm-none-linux-gnueabi-ar)
SET(CMAKE_LD /usr/bin/ld)
SET(CMAKE_C_LINK_EXECUTABLE "/scratchbox/compilers/bin/gcc <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

I have put together a quick test program with the following CMakeLists.txt

add_executable (test test.c)

All is good when I run
cmake -DCMAKE_TOOLCHAIN_FILE=../arm_cross.cmake .

then on running make I get

Scanning dependencies of target test
[100%] Building C object CMakeFiles/test.dir/test.c.o
Linking C executable test
/scratchbox/compilers/arm-linux-cs2010q1-202/bin/sbox-arm-none-linux-gnueabi-gcc: No such file or directory
make[2]: *** [test] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2

I have tried it with and without the last line in the target file and the result is the same. If I force it to use the ARM version of gcc for linking by setting SET(CMAKE_C_LINK_EXECUTABLE "/usr/bin/gcc <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

then it fails on a call to ld, which it guesses correctly but complians with the following output

Linking C executable test
sb_gcc_wrapper (/scratchbox/compilers/bin/ld): /scratchbox/compilers/arm-linux-cs2010q1-202/bin/sbox-arm-none-linux-gnueabi-ld: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [test] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2

Why is it that it doesn't like using the cross compiler for linking? How do I get this to work?

TIA

Christian


_______________________________________________
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