AFSIM入门教程03.04:Linux PC下编译

系列索引:AFSIM入门教程索引

AFSIM入门教程03.03:更新所有依赖库版本中介绍了如何更新所有依赖库版本。我们得出结论,不要轻易更新依赖库版本,那么在Linux下直接使用Windows指定版本进行编译。

官方没有提供Linux版预编译打包的库。本文试试在Linux PC上编译,最常用的环境就是Ubuntu了,这里选择Ubuntu 24.04.03 LTS(2026.01.03)英文版。

环境

准备一个全新的系统[1]

1
2
3
4
5
6
sudo apt update # 更新软件包缓存
sudo apt upgrade #更新软件
sudo apt install cmake cmake-gui gcc-9 g++-9 make ccache cppcheck sphinx git build-essential pkg-config doxygen python3-pip graphviz m4 libtool autoconf automake tcl python3
sudo apt install libglu1-mesa-dev libgl1-mesa-dev freeglut3-dev #opengl
sudo apt-get install git '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev flex libicu-dev libxslt-dev ruby libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libegl1-mesa-dev gperf bison nodejs libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev libbz2-dev libcups2-dev libdrm-dev libgcrypt* gyp ninja-build pulseaudio* libthread*
sudo apt install clang libclang-dev #编译qt

所有afsim需要的库全部自己编译。

依赖库

官方提供的依赖库名称、版本;Linux版对应名称、版本;库使用情况如下表所示。

2025.06.21检测

名称版本使用
curl7.79.1
freetype2.9.1
ffmpeg4.2.4
gdal3.3.2
geos3.5.1
gsl2.1
gtest1.8.0
jpeg9d
libpng1.6.37
osg3.6.3
osgEarth2.10.1
proj8.1.1
protobuf3.6.1/3.7.1/3.9.1
pybind112.6.2
qt5.12.11
sdl2.0.16
sqlite3.32.3
tiff4.3.0
tinyxml27.1.0
yasm1.3.0
zlib1.2.11
zmq4.3.1/4.3.2

下载

下载用到的库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
https://github.com/curl/curl/releases/download/curl-7_79_1/curl-7.79.1.tar.gz
https://github.com/gwaldron/osgearth/archive/refs/tags/osgearth-2.10.1.tar.gz
https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.2.4.tar.gz
https://github.com/google/googletest/archive/refs/tags/release-1.8.0.tar.gz
https://github.com/OSGeo/gdal/releases/download/v3.3.2/gdal-3.3.2.tar.gz
https://github.com/libgeos/geos/archive/refs/tags/3.5.1.tar.gz
https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/2.1.2/libjpeg-turbo-2.1.2.tar.gz
https://github.com/openssl/openssl/releases/download/openssl-3.1.1/openssl-3.1.1.tar.gz
https://github.com/openscenegraph/OpenSceneGraph/archive/refs/tags/OpenSceneGraph-3.6.3.tar.gz
https://github.com/OSGeo/PROJ/releases/download/8.1.1/proj-8.1.1.tar.gz
https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.37.tar.gz
https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.0.16.tar.gz
https://github.com/sqlite/sqlite/archive/refs/tags/version-3.32.3.tar.gz
https://gitlab.com/libtiff/libtiff/-/archive/v4.3.0/libtiff-v4.3.0.tar.gz
https://github.com/leethomason/tinyxml2/archive/refs/tags/7.1.0.tar.gz
https://github.com/madler/zlib/archive/refs/tags/v1.2.11.tar.gz
https://sourceforge.net/projects/tcl/files/Tcl/8.6.15/tcl8.6.15-src.tar.gz/download

库编译

根据别人的脚本[2]修改。

编译

库编译完成,按照AFSIM入门教程03.01:Windows下编译中的步骤,编译源码。

技巧

脚本调试

如果shell脚步使用过程中出现问题,可以使用命令

1
2
sh -n build.sh #检查语法问题
sh -x build.sh #输出shell运行过程

脚步编写

变量设置时尽量用"包起来,防止赋值字符串包含不需要的字符。

错误

source无法找到

查看sh

1
ls -l /bin/sh #这里输出dash

将其切换为bash

1
2
3
4
sudo dpkg-reconfigure dash #输入no,然后一路enter。
sudo unlink /bin/sh #解除
sudo ln -s /bin/bash /bin/sh #建立链接
ls -l /bin/sh

移植

我测试了一下平台的移植。

  • Linux ARM
  • 银河麒麟

参考资料


AFSIM入门教程03.04:Linux PC下编译
https://blog.jackeylea.com/afsim/how-to-build-afsim-in-ubuntu/
作者
JackeyLea
发布于
2025年8月1日
许可协议