I have a broken C Compiler when I use CLion
with yocto SDK
, but it works fine on eclipse Oxygen
.
This is the error in the compiler:
CMake Error at /home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler
"/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc"
is not able to compile a simple test program.
And this is the log error:
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find crt1.o: No such file or directory
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find crti.o: No such file or directory
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find crtbegin.o: No such file or directory
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find -lgcc
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find -lgcc_s
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find -lc
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find -lgcc
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find -lgcc_s
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find crtend.o: No such file or directory
/home/developer/yocto_SDK2/toolchain2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/6.4.0/real-ld: cannot find crtn.o: No such file or directory
I have also configured the paths manually, and it was fine.
[![enter image description here][1]][1]
Does anyone know how to resolve this problem for the gcc compiler ?
So after researching, trying and failing all the possible options, I found my answer which is the following:
Apparently Clion can't detect the Compilers unless I source
and cmake
before launching Clion, so it could redirect the Compilers to Yocto compilers rather than detecting the host Compilers.
So, I created the following Bash script which launches the mentioned commands.
Sourcing setup_sdk as follows:
#!/bin/bash
# define root paths
export SDK_TC_ROOT=~/yocto_sdk/toolchain
# source yocto sdk stuff
source ${SDK_TC_ROOT}/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
Then, I ran the following bash code to make sure that the setup runs correctly before launching Clion
#!/bin/bash
PATH_TO_Clion=~/clion/bin
# setup env
source setup_sdk
cmake ./
# start Clion with all variables
$PATH_TO_Clion/clion.sh
Then Clion auto-detected the Compilers correctly without defining them manually which resulted to the mentioned C Compiler Issue.
It is worth to mention that Clion somehow doesn't accept the -
parameter when defining Cmake Options in CMAKE_TOOLCHAIN_FILE=
. As it compiled and build correctly for me.