Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    glibc工具链构建应用

    V853系列-AI视觉
    1
    1
    231
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RiceChen LV 4 last edited by

      buildroot构建,应用交叉编译

      1. 为啥要写交叉编译呢?是因为全志提供的文档中描述的OpenWRT的构建方式,而我采用的buildroot进行构建。他们两者采用的交叉工具链是不一样的。其中:OpenWRT采用musl工具链,而buildroot采用的glibc工具链。

      2. 为了避免其他人采用buildroot也按照文档进行操作,导致应用编译完无法运行起来。所以我补充一下buildroot构建中,应用的交叉编译。

      3. 编写HelloWorld:

      #include <stdio.h>
      
      int main(void)
      {
         printf("Hello World!");
         return 0;
      }
      
      
      1. V853的编译工具链的路径:prebuilt/rootfsbuilt/arm/。里面包含了两个工具链:musl和glibc,而buildroot采用了glic。
      2. 所以gcc编译器的路径:prebuilt/rootfsbuilt/arm/toolchain-sunxi-glibc-gcc-830/toolchain/bin/。而编译是需要用到的库文件和头文件路径:prebuilt/rootfsbuilt/arm/toolchain-sunxi-glibc-gcc-830/toolchain/arm-openwrt-linux-gnueabi/
      3. 指定存放交叉编译需要使用的库文件头文件的文件夹
      v853@v853:~/$ export STAGING_DIR=~/v853/tina-v853/prebuilt/rootfsbuilt/arm/toolchain-sunxi-glibc-gcc-830/toolchain/arm-openwrt-linux-gnueabi/
      
      1. 编译应用程序:
      v853@v853:~/$ export STAGING_DIR=~/v853/tina-v853/prebuilt/rootfsbuilt/arm/toolchain-sunxi-glibc-gcc-830/toolchain/bin/arm-openwrt-linux-gcc -o helloworld main.c
      v853@v853:~/$ ls
      helloworld main.c
      v853@v853:~/$
      
      1. 我是采用挂载SD卡的形式将应用程序拷贝到板子的。所以将编译好的应用程序helloworld拷贝到SD卡。
      2. 板子上验证结果:
      // 挂载SD卡到test目录上
      # mount /dev/mmcblk1 /mnt/test/
      // 运行应用
      # ./helloworld
      Hello World!# 
      
      1 Reply Last reply Reply Quote Share 0
      • 1 / 1
      • First post
        Last post

      Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策