当我将CLion
与yocto SDK
一起使用时,我的C编译器损坏了,但是在eclipse Oxygen
上可以正常工作。
这是编译器中的错误:
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.
这是日志错误:
/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
我还手动配置了路径,这很好。 [![在此处输入图片描述] [1]] [1]
有人知道如何为gcc编译器解决此问题吗?
答案 0 :(得分:2)
因此,在研究,尝试和失败所有可能的选择之后,我找到了以下答案:
显然,除非我在启动 Clion 之前source
和cmake
,否则 Clion 无法检测到编译器,因此它可以将编译器重定向到 Yocto 编译器,而不是检测主机编译器。
因此,我创建了以下 Bash 脚本,用于启动上述命令。
采购 setup_sdk 如下:
#!/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
然后,我运行以下 bash 代码,以确保安装程序在启动 Clion
之前正确运行#!/bin/bash
PATH_TO_Clion=~/clion/bin
# setup env
source setup_sdk
cmake ./
# start Clion with all variables
$PATH_TO_Clion/clion.sh
然后Clion无需手动定义即可正确地自动检测到编译器,从而导致上述 C编译器问题。
值得一提的是,在-
中定义 Cmake选项时, Clion 不接受CMAKE_TOOLCHAIN_FILE=
参数。它为我正确编译和构建。
答案 1 :(得分:0)
我有一个类似的问题。 我的情况虽然复杂一些。我需要在默认工具链(x86)和yocto交叉编译工具链(ARM)之间切换,以编译同一项目。
我提出以下解决方案:
#!/bin/bash
source ~/yocto_sdk/toolchain/environment-setup-cortexa9hf-neon-poky-linux-gnueabi; bash -c "cmake $(printf ' %q' "$@")" C