tags:

views:

527

answers:

2

Hi! I want to setup a custom toolchain with qmake. I've set the compiler but I don't know how to set the linker. This error is reported because cmake try to use the compiler to link:

The C compiler "xgcc.exe" is not able to compile a simple test program.

Here there is a snippet of my toolchain file

# specify the cross compiler
INCLUDE(CMakeForceCompiler)
SET(CMAKE_C_COMPILER   xgcc.exe)
SET(CMAKE_CXX_COMPILER xgcc.exe)
#CMAKE_FORCE_C_COMPILER(xgcc.exe GNU)
#CMAKE_FORCE_CXX_COMPILER(xgcc.exe GNU)

I've tried to force the compiler but the linker problem will not be solved.

+1  A: 

Set the variable ${CMAKE_LINKER} either in CMakeCache.txt or after ccmake . under advanced options.

drhirsch
Can I set it in CMakeLists.txt?I 've just looked for CMAKE_LINKER in the cmake man page but I cannot find it. Are You sure about the name of the variable?
Breezeight
Yes. Invoke `ccmake .` in your build directory and press 't'. Scroll down until you hit CMAKE_LINKER.
drhirsch
Sure but when I compile the project for the first time I start with cmake -DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake . And this generate an error.
Breezeight
AFAIK there is a "CACHE" option for the SET command, you could try to use ist for setting CMAKE_LINKER in CMakeLists.txt. Or try `cmake -DCMAKE_LINKER=yourlinker -DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake`
drhirsch
Ok! Now the CMAKE_LINKER variable is ok but cmake still want to link with xgcc. :(
Breezeight
Hmm, it shouldn't. File a bug at http://public.kitware.com/Bug/my_view_page.php
drhirsch
+1  A: 

I have to use CMAKE_CXX_LINK_EXECUTABLE, CMAKE_C_LINK_EXECUTABLE variable:

SET(CMAKE_C_LINK_EXECUTABLE "c:\\MoSync\\bin\\pipe-tool.exe")
Breezeight