系列索引:AFSIM入门教程索引
在AFSIM入门教程03.03:更新所有依赖库版本中介绍了如何更新所有依赖库版本。我们得出结论,不要轻易更新依赖库版本,那么在Linux下直接使用Windows指定版本进行编译。
官方没有提供Linux版预编译打包的库。本文试试在Linux PC上编译,最常用的环境就是Ubuntu了,这里选择Ubuntu 24.04.03 LTS(2026.01.03)英文版。
环境
准备一个全新的系统。
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 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
|
所有afsim需要的库全部自己编译。
依赖库
官方提供的依赖库名称、版本;Linux版对应名称、版本;库使用情况如下表所示。
2025.06.21检测
| 名称 | 版本 | 使用 |
|---|
| curl | 7.79.1 | |
| freetype | 2.9.1 | |
| ffmpeg | 4.2.4 | √ |
| gdal | 3.3.2 | √ |
| geos | 3.5.1 | √ |
| gsl | 2.1 | |
| gtest | 1.8.0 | √ |
| jpeg | 9d | |
| libpng | 1.6.37 | |
| osg | 3.6.3 | √ |
| osgEarth | 2.10.1 | √ |
| proj | 8.1.1 | √ |
| protobuf | 3.6.1/3.7.1/3.9.1 | |
| pybind11 | 2.6.2 | |
| qt | 5.12.11 | √ |
| sdl | 2.0.16 | √ |
| sqlite | 3.32.3 | √ |
| tiff | 4.3.0 | √ |
| tinyxml2 | 7.1.0 | √ |
| yasm | 1.3.0 | |
| zlib | 1.2.11 | |
| zmq | 4.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
|
库编译
根据别人的脚本修改。
编译
库编译完成,按照AFSIM入门教程03.01:Windows下编译中的步骤,编译源码。
技巧
脚本调试
如果shell脚步使用过程中出现问题,可以使用命令
1 2
| sh -n build.sh sh -x build.sh
|
脚步编写
变量设置时尽量用"包起来,防止赋值字符串包含不需要的字符。
错误
source无法找到
查看sh
将其切换为bash
1 2 3 4
| sudo dpkg-reconfigure dash sudo unlink /bin/sh sudo ln -s /bin/bash /bin/sh ls -l /bin/sh
|
移植
我测试了一下平台的移植。
参考资料