[CMake] Problem using CMake for cross compiling for linux

Thomas Baag baag at ice.rwth-aachen.de
Fri Nov 29 08:13:50 EST 2013


On Thursday 28 November 2013 23:04:48 Magnus Therning wrote:
> On Thu, Nov 28, 2013 at 04:05:18PM +0100, Thomas Baag wrote:
> > Hi folks,
> >
> > i'm trying to cross compile a simple hello world on Scientific Linux 6.4
> > (amd64) using cmake version 2.8.4 and arm-none-eabi-gcc 4.8.1. I've
> > encountered the well known "-rdynamic" problem[1], but couldn't manage to
> > apply a nice workaround.
> >
> > I DONT want to disable simple compiler checks. The problem seems to be in
> > the "__linux_compiler_gnu" macro in "Modules/Platform/Linux-GNU.cmake".
> >
> > Until now i tried
> > SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
> > SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
> > before and after "PROJECT(...)", but it didn't work.
> > After that, I added this on top of my CMakeList.txt:
> > SET(__LINUX_COMPILER_GNU 1)
> > MACRO(__linux_compiler_gnu lang)
> >  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
> > ENDMACRO()
> > But it also didnt work.
> >
> > Now i'm somehow out of ideas. Could anyone pls help?
> >
> >
> > Greetings
> > Thomas
> >
> > [1] http://www.cmake.org/Bug/view.php?id=9985
> >
> >
> > ================
> > # Minimal CMakeList.txt:
> > CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
> >
> > SET(__LINUX_COMPILER_GNU 1)
> > MACRO(__linux_compiler_gnu lang)
> >  SET(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
> > ENDMACRO()
> >
> > PROJECT(Build-Example)
> >
> > ================
> > # Minimal toolchain file:
> > SET(CMAKE_SYSTEM_NAME Linux)
> > SET(CMAKE_SYSTEM_PROCESSOR "armv7")
> > SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
> 
> The only way I found around this was
> 
>     set(CMAKE_SYSTEM_NAME Generic )
> 
> but I think that is exactly what you want to avoid given your comment
> about "I DONT want to disable simple compiler checks."
> 
> /M
> 

Problem solved. I made a mistake by trying to use bare metal gcc (arm-none-
eabi-gcc) to compile application for Linux target. With an arm-linux-eabi-gcc 
everything works fine.

Bye
Thomas


More information about the CMake mailing list