已gitee 上 asio2 框架为例,
asio2: 基于asio的网络通信框架asio2,支持tcp,udp,http,websocket,rpc,ssl,icmp,serial_port.,跨平台,支持可靠UDP,支持TCP自动拆包等
CMakeLists文件,在项目example下 增加编译工具链配置
set(CMAKE_SYSTEM_PROCESSOR arm64)
set(CMAKE_C_COMPILER /usr/lib/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/lib/aarch64-linux-gnu-g++)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
增加编译工具链配置 ,在example 目录下新建build文件夹 ,进入build文件夹执行命令
cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_EXE_LINKER_FLAGS=-static ..
将会把构建内容生成到 build 目录下,
同时在 bin 目录下(/home/hongyawx/wuxu/asio2-main/example/bin/x64)生成 可执行文件
hongyawx@hongyawx:~/wuxu/asio2-main/example/bin/x64$ file http_client
http_client: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=c2313dd1ebb13c4b5928d56081dbe51476d0e7ab, for GNU/Linux 3.7.0, with debug_info, not stripped
其中 statically linked, 表示使用静态编译