五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

構(gòu)建樹莓派交叉編譯環(huán)境(基于虛擬機(jī)ubuntu18)

2023-06-09 19:25 作者:碗仔粿  | 我要投稿

首先,建議在root用戶下進(jìn)行環(huán)境搭建,因?yàn)橛行┲噶畈僮鞯哪夸洐?quán)限只有root用戶才有,而環(huán)境變量添加是按照用戶添加的,構(gòu)建交叉編譯環(huán)境的過程中使用su 指令獲取root用戶權(quán)限的時(shí)候會(huì)將之前加入的環(huán)境變量清空,導(dǎo)致找不到相關(guān)文件。

樹莓派采用64位ubuntu20系統(tǒng)

一、搭建交叉編譯工具

  1. 下載對應(yīng)樹莓派版本的相關(guān)軟件包

    在樹莓派上使用如下命令進(jìn)行查看版本信息

    1.Binutils版本 ld -v? ? ? ? ? ?本機(jī)2.34

    2.GCC版本 gcc -v? ? ? ? ? ? 本機(jī)9.4.0

    3.GLIBC版本 ldd --version? ? 本機(jī)2.31

    4.樹莓派linux內(nèi)核版本 uname -a? ?本機(jī)5.4.0-1085-raspi

    上國內(nèi)鏡像資源網(wǎng)站下載對應(yīng)版本上述資源(這里使用清華鏡像)在下述地址下載1-3

    https://mirrors.tuna.tsinghua.edu.cn/gnu

    在樹莓派官網(wǎng)下載相應(yīng)版本Linux內(nèi)核

    https://github.com/raspberrypi/linux

2.將下載好的壓縮包放到虛擬機(jī)ubuntu的文件夾下

????我們在用戶的home目錄下新建gcc_all文件夾用于存放相關(guān)文件

????????????1? ?cd ~?

?????????2?mkdir gcc_all && cd gcc_all

?然后將壓縮包拖進(jìn)去(用鼠標(biāo)托。。別問我怎么托),解壓壓縮包

????????1?tar xf binutils-2.34.tar.bz2?

????????2 tar xf glibc-2.31.tar.bz2?

????????3 tar xf gcc-9.4.0.tar.gz?

????????4.unzip linux-rpi-5.4.y.zip

3.在GCC文件夾中下載prerequisite

????????1?cd gcc-9.4.0?

??2 contrib/download_prerequisites

4.在opt目錄下創(chuàng)建文件夾用于存放交叉編譯工具(opt文件是我們存放用戶自定義文件的地方)然后將文件路徑添加到環(huán)境變量中(不添加后續(xù)編譯會(huì)報(bào)錯(cuò))

????????1 cd ~/gcc_all?

????????2 sudo mkdir -p /opt/cross-pi-gcc?

????????3 sudo chown $USER /opt/cross-pi-gcc?

????????4 export PATH=/opt/cross-pi-gcc/bin:$PATH

5.復(fù)制內(nèi)核頭文件

????????????1??cd ~/gcc_all?

????????????2??cd linux?

????????????3??KERNEL=kernel7?

????????????4??make ARCH=arm INSTALL_HDR_PATH=/opt/cross-pi-gcc/arm-linux-gnueabihf? ? ? ? ? headers_install

6.構(gòu)建binutils

????????????1 cd ~/gcc_all?

????????????2 mkdir build-binutils && cd build-binutils?

????????????3 ../binutils-2.34/configure --prefix=/opt/cross-pi-gcc --target=arm-linux-gnueabihf --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-multilib?

????????????4 make -j 8?

? ? 5 make install

7.構(gòu)建部分gcc

????????????1 cd ~/gcc_all?

????????????2 mkdir build-gcc && cd build-gcc?

????????????3 ../gcc-9.4.0/configure --prefix=/opt/cross-pi-gcc --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-multilib?

????????????4 make -j8 all-gcc?

????????????5 make install-gcc

8.構(gòu)建glibc

????????????1 cd ~/gcc_all?

????????????2 mkdir build-glibc && cd build-glibc?

????????????3 ../glibc-2.31/configure --prefix=/opt/cross-pi-gcc/arm-linux-gnueabihf --build=$MACHTYPE --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-arch=armv6 --with-fpu=vfp --with-float=hard --with-headers=/opt/cross-pi-gcc/arm-linux-gnueabihf/include --disable-multilib libc_cv_forced_unwind=yes?

????????????4 make install-bootstrap-headers=yes install-headers?

????????????5 make -j8 csu/subdir_lib?

????????????6 install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross-pi-gcc/arm-linux-gnueabihf/lib?

????????????7 arm-linux-gnueabihf-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross-pi-gcc/arm-linux-gnueabihf/lib/libc.so?

????????????8 touch /opt/cross-pi-gcc/arm-linux-gnueabihf/include/gnu/stubs.h

9.回到gcc編譯

????????????1 cd ..?

????????????2 cd build-gcc?

????????????3 make -j8 all-target-libgcc?

????????????4 make install-target-libgcc

10.完成glibc編譯

????????????1 cd ..?

????????????2 cd build-glibc?

????????????3 make -j8?

????????????4 make install
11.完成GCC交叉編譯工具9.4.0搭建

????????????1 cd ..?

????????????2 cd build-gcc?

????????????3 make -j8?

????????????4 make install

二、測試交叉編譯工具

寫一個(gè)hello,world程序 c/c++都可以(這個(gè)自己寫。。)

????????????? ?arm-linux-gnueabihf-g++/gcc?test.cpp/c -o test

我用的C++所以執(zhí)行如下:

????arm-linux-gnueabihf-g++?hello.cpp -o hello

將生成的二進(jìn)制文件,復(fù)制到樹莓派上(使用xftp或者u盤都可以)

????????????????chmod +x? 文件名? ? (添加可執(zhí)行權(quán)限)

????????????????./文件名? ?(執(zhí)行)

????????????????輸出hello,world 則交叉編譯工具搭建完成


三、可能遇到問題

  1. 將編譯出的可執(zhí)行文件放到樹莓派上無法運(yùn)行(報(bào)錯(cuò) No such file or directory)

    因?yàn)檫@個(gè)交叉編譯工具是32位的? 如果樹莓派的系統(tǒng)版本是64位則無法執(zhí)行

    解決方法:

    ? ? ? ? ?1.采用靜態(tài)編譯:加入 - static 關(guān)鍵字

    ? ? ? ? ? ?arm-linux-gnueabihf-g++?hello.cpp?-static -o hello

    ? ? ? ? ? ?缺點(diǎn):生成的可執(zhí)行文件變得很大。。。。。

  2. 在進(jìn)行交叉工具生成過程中出現(xiàn)權(quán)限不夠:直接切換root用戶(記得重新添加環(huán)境變量。)



構(gòu)建樹莓派交叉編譯環(huán)境(基于虛擬機(jī)ubuntu18)的評論 (共 條)

分享到微博請遵守國家法律
西青区| 石家庄市| 盱眙县| 那坡县| 云浮市| 西充县| 沁阳市| 岳阳县| 五莲县| 安溪县| 定西市| 昭通市| 东兴市| 大邑县| 信阳市| 芦溪县| 郑州市| 盖州市| 囊谦县| 奉节县| 休宁县| 双鸭山市| 黄大仙区| 浦北县| 绥中县| 萨嘎县| 荃湾区| 乾安县| 永登县| 通山县| 交口县| 仁寿县| 巴彦淖尔市| 怀安县| 米林县| 烟台市| 四子王旗| 贞丰县| 房山区| 海阳市| 高碑店市|