Ubuntu cross-compiled arm framework (mobile phone can run)

The executable program compiled under Ubuntu (gcc) is put into the mobile phone to run, and the report is not executable: 64-bit ELF file

        Reason: The CPU on the PC is based on the X86 structure, and the Android device is mainly based on ARM, which requires cross-compilation.

Use the cross-compilation tool arm-none-linux-gnueabi-gcc to compile, download link

# 解压
tar -xjvf  arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

# 可运行文件(在解压文件的bin目录下)
cd arm-2010.09/bin

# 查看信息
./arm-none-linux-gnueabi-gcc --version

# 配置环境变量
vim ~/.bashrc

# 修改PATH变量
export PATH=$PATH:/home/.../arm-2010.09/bin  #文件末尾添加

# 生效
source ~/.bashrc

# 交叉编译
arm-none-linux-gnueabi-gcc -static xxx.cpp -o xxx # -o指定输出名字

# 移动端运行

adb push 
xxx

        This version is too old to run the c++11 version

Replace the cross-compilation chain tool arm-linux-gnueabihf-gcc, download address

The operation is the same as above, and then use the arm-linux-gnueabihf-g++ command

Guess you like

Origin blog.csdn.net/qq_38295645/article/details/130308042