当前位置:网站首页>使用cmake交叉编译helloworld
使用cmake交叉编译helloworld
2022-06-13 05:23:00 【蓝牙先生】
主机环境
cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
cmake版本
cmake --version
cmake version 3.16.3
helloworld.c
[email protected]:/mnt/lab/cmake_helloworld$ cat helloworld.c
#include <stdio.h>int main(int argc, char *argv[])
{
printf("hello world\n");
return 0;
}
CMakeLists.txt
[email protected]:/mnt/lab/cmake_helloworld$ cat CMakeLists.txt
project(helloworld_project)cmake_minimum_required(VERSION 3.16)
set (CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set (CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)add_executable(helloworld helloworld.c)
执行cmake命令生成Makefile
[email protected]:/mnt/lab/cmake_helloworld$ cmake .
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/lab/cmake_helloworld
执行make命令
[email protected]:/mnt/lab/cmake_helloworld$ make
Scanning dependencies of target helloworld
[ 50%] Building C object CMakeFiles/helloworld.dir/helloworld.c.o
[100%] Linking C executable helloworld
[100%] Built target helloworld
查看生成的helloworld格式
[email protected]:/mnt/lab/cmake_helloworld$ file helloworld
helloworld: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=64931729ed98ba097ffafab33a540e307404aaf9, for GNU/Linux 3.7.0, not stripped
交叉编译成功
边栏推荐
- Wang Dao Chapter II linear table exercises
- MySQL installation, architecture and management
- MySQL advanced query
- ZABBIX proxy, sender (without agent monitoring), performance optimization
- [thread / multithread] execution sequence of threads
- Simple greedy strategy
- MySQL built-in functions
- Clause 30: be familiar with the failure of perfect forwarding
- Small project - household income and expenditure software (1)
- Celery understands
猜你喜欢

MySQL built-in functions

About anonymous inner classes

安装harbor(在线|离线)

Pycharm错误解决:Process finished with exit code -1073741819 (0xC0000005)

Metaltc4.0 stable release

Binary search and binary answer

890. Find and Replace Pattern

Float type value range

Chapter 15 mechanism: Address Translation

Sort (internal sort) + external sort
随机推荐
Mysql database crud operation
Use of mongodb
Luogu p1012 guess
C language learning log 1.24
Information collection for network security (2)
Dup2 use
KVM virtualization management tool
lookup
Dynamic and static libraries
17.6 unique_lock详解
About anonymous inner classes
动态规划-最长公共子串
Simple SR: best buddy Gans for highly detailed image super resolution
Chapter 2 process management
Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases
Modification and analysis of libcoap source code by Hongmeng device discovery module
[thread / multithread] execution sequence of threads
关于匿名内部类
About Evaluation Metrics
BM1Z002FJ-EVK-001开机测评