本文來(lái)源電子發(fā)燒友社區(qū),作者:大菠蘿Alpha, 帖子地址:https://bbs.elecfans.com/jishu_2309329_1_1.html
因?yàn)橐恢庇肬buntu 20.04環(huán)境,沒(méi)有使用官方的VMWARE鏡像搭建環(huán)境,所以直接開(kāi)貼來(lái)一篇。
一、開(kāi)發(fā)環(huán)境準(zhǔn)備
(一)操作系統(tǒng)
使用的是Ubuntu 20.04。
root@EliteDesk:/$ uname -a
Linux EliteDesk 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
(二)Cmake
執(zhí)行sudo apt install cmake
命令安裝cmake。
root@EliteDesk:/$ sudo apt install cmake
[sudo] password for root:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
cmake-data libjsoncpp1 librhash0
Suggested packages:
cmake-doc ninja-build
The following NEW packages will be installed:
cmake cmake-data libjsoncpp1 librhash0
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,470 kB of archives.
After this operation, 28.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu focal/main amd64 cmake-data all 3.16.3-1ubuntu1 [1,612 kB]
Get:2 http://mirrors.aliyun.com/ubuntu focal/main amd64 libjsoncpp1 amd64 1.7.4-3.1ubuntu2 [75.6 kB]
Get:3 http://mirrors.aliyun.com/ubuntu focal/main amd64 librhash0 amd64 1.3.9-1 [113 kB]
Get:4 http://mirrors.aliyun.com/ubuntu focal/main amd64 cmake amd64 3.16.3-1ubuntu1 [3,669 kB]
Fetched 5,470 kB in 4s (1,397 kB/s)
Selecting previously unselected package cmake-data.
(Reading database ... 221845 files and directories currently installed.)
Preparing to unpack .../cmake-data_3.16.3-1ubuntu1_all.deb ...
Unpacking cmake-data (3.16.3-1ubuntu1) ...
Selecting previously unselected package libjsoncpp1:amd64.
Preparing to unpack .../libjsoncpp1_1.7.4-3.1ubuntu2_amd64.deb ...
Unpacking libjsoncpp1:amd64 (1.7.4-3.1ubuntu2) ...
Selecting previously unselected package librhash0:amd64.
Preparing to unpack .../librhash0_1.3.9-1_amd64.deb ...
Unpacking librhash0:amd64 (1.3.9-1) ...
Selecting previously unselected package cmake.
Preparing to unpack .../cmake_3.16.3-1ubuntu1_amd64.deb ...
Unpacking cmake (3.16.3-1ubuntu1) ...
Setting up librhash0:amd64 (1.3.9-1) ...
Setting up cmake-data (3.16.3-1ubuntu1) ...
Setting up libjsoncpp1:amd64 (1.7.4-3.1ubuntu2) ...
Setting up cmake (3.16.3-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
二、安裝交叉編譯工具鏈
直接使用官方下載的rv1126_rv1109_compiler_20220715_175105.tar.gz 文件,執(zhí)行sudo tar xvf rv1126_rv1109_compiler_20220715_175105.tar.gz -C /
千萬(wàn)記得加上sudo,不要問(wèn)為什么。
root@EliteDesk:/$ sudo tar xvf rv1126_rv1109_compiler_20220715_175105.tar.gz -C /
[sudo] password for root:
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/cc1plus
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/collect2
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/liblto_plugin.so.0.0.0
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/install-tools/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/install-tools/mkinstalldirs
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/install-tools/fixincl
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/install-tools/mkheaders
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/install-tools/fixinc.sh
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/f951
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/plugin/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/plugin/gengtype
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/lto-wrapper
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/liblto_plugin.so
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/liblto_plugin.so.0
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/lto1
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/8.3.0/cc1
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/8.3-2019.03-x86_64-arm-linux-gnueabihf-manifest.txt
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/share/
opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/share/locale/
然后坐等安裝完成。
設(shè)置環(huán)境變量,將剛才安裝的SDK包含:
root@EliteDesk:/media/rv1126$ export PATH=/opt/rv1126_rv1109_sdk/buildroot/output/rockchip_face_board/host/bin:$PATH
root@EliteDesk:/media/rv1126$ export ARCH=arm
root@EliteDesk:/media/rv1126$ export CROSS_COMPILE=arm-linux-gnueabihf-
測(cè)試交叉編譯環(huán)境是否安裝成功:
root@EliteDesk:/media/rv1126$ qmake -v
QMake version 3.1
Using Qt version 5.15.2 in /opt/rv1126_rv1109_sdk/buildroot/output/rockchip_face_board/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib
root@EliteDesk:/media/rv1126$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rv1126_rv1109_sdk/buildroot/../prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/rv1126_rv1109_sdk/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/8.3.0/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/gcc/configure --target=arm-linux-gnueabihf --prefix= --with-sysroot=/arm-linux-gnueabihf/libc --with-build-sysroot=/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/install//arm-linux-gnueabihf/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpfr=/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpc=/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-isl=/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-arch=armv7-a --with-pkgversion='GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)'
Thread model: posix
gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36))
OK,一切正常。
三、HELLO Easy EAI
來(lái)個(gè)hello小程序吧。
#include
#include
int main(void)
{
int i;
for(i = 0; i < 5; i++) {
printf("hello Easy EAI!%d n", i);
}
return 0;
}
這樣就好,之后執(zhí)行arm-linux-gnueabihf-gcc hello.c -o hello
,生成ARM的可執(zhí)行程序hello,再通過(guò)adb push hello /userdata
到開(kāi)發(fā)板。
adb shell
登錄到開(kāi)發(fā)板,執(zhí)行程序,執(zhí)行之前記得chmod修改下屬性。
-
開(kāi)發(fā)板
+關(guān)注
關(guān)注
25文章
4900瀏覽量
97065 -
Ubuntu
+關(guān)注
關(guān)注
5文章
559瀏覽量
29503
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論