linux单独编译.c文件,使用yocto的工具链单独编译C文件

本文转载自CSDN,点击此处访问原文!

1.Restarting a build environment

source setup-environment

2.gcc工具链

bitbake meta-toolchain

./tmp/deploy/sdk/poky-glibc-x86_64-meta-toolchain-cortexa7hf-vfp-neon-toolchain-1.8.sh

3.QT工具链

bitbake meta-toolchain-qt5

4.编译uboot

source /opt/poky/1.8/environment-setup-cortexa7hf-vfp-neon-poky-linux-gnueabi

make mx6ul_14x14_evk_defconfig

make

5.编译kernel

export ARCH=arm

export CROSS_COMPILE=$TARGET_PREFIX

unset LDFLAGS

make imx_v7_defconfig

make uImage LOADADDR=0x10008000

make命令会生成Linux的dtb文件

6.单独编译C文件

yangzhiwen@yzw-kingsee:~$ cd /home/work/Elmo/test/test/

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ ls

main.c test

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ rm test

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ cat main.c

#include "stdlib.h"

#include "stdio.h"

void main(void)

{

printf("Hello world\n");

}

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ source /opt/poky/1.8/environment-setup-cortexa7hf-vfp-neon-poky-linux-gnueabi

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ echo $CC

arm-poky-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/poky/1.8/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ $CC main.c -o test

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$ file test

test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=ad28e302b106823c7cbcd038f9cb4940c14b5f57, not stripped

yangzhiwen@yzw-kingsee:/home/work/Elmo/test/test$

如果不设置好环境,交叉编译工具就找不到头文件,下面是我自己的编译环境

marvin@ubuntu:cantool$ source /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

marvin@ubuntu:cantool$ export ARCH=arm

marvin@ubuntu:cantool$ export CROSS_COMPILE=arm-poky-linux-gnueabi-

marvin@ubuntu:cantool$ echo $CC

arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi

marvin@ubuntu:cantool$ $CC ./cantool.c -o cantool-arm

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值