error: unrecognized command-line option '-rdynamic'

155 Views Asked by At

When I generate my build for cross compilation for arm-none-eabi with cmake I have this error:

... is not able to compile a simple test program
...error: unrecognized command-line option '-rdynamic'

I have try to add the flag -Wl,-export-dynamic in toolchain file but -rdynamic is added by cmake

arm-none-eabi-gcc -Wl,-export-dynamic  -rdynamic CMakeFiles/cmTC_803b3.dir/testCCompiler.c.o -o cmTC_803b3

How can I remove it ?

1

There are 1 best solutions below

0
vict On

Ignoring that rdynamic part, the real problem is that CMake is trying to do a compiler check on your machine and your cross-compilation toolchain fails. This is to be expected because the arm-compiler is for the, well... arm machine and you are probably using something else as your workstation.

So make sure to disable the compiler check in your toolchain file. Most of the time it is simply enough to add set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY).