准备
设置麒麟系统安全状态为Softmode (防止编译时出现权限不够问题)
sudo setstatus Softmode
getstatus
安装g++
sudo apt-get install build-essential
安装依赖库
sudo apt-get install \
bison \
ca-certificates \
ccache \
cmake \
cmake-curses-gui \
dh-python \
doxygen \
expect \
flex \
flip \
gdal-bin \
git \
graphviz \
grass-dev \
libexiv2-dev \
libexpat1-dev \
libfcgi-dev \
libgdal-dev \
libgeos-dev \
libgsl-dev \
libpdal-dev \
libpq-dev \
libproj-dev \
libprotobuf-dev \
libqca-qt5-2-dev \
libqca-qt5-2-plugins \
libqscintilla2-qt5-dev \
libqt5opengl5-dev \
libqt5serialport5-dev \
libqt5sql5-sqlite \
libqt5svg5-dev \
libqt5webkit5-dev \
libqt5xmlpatterns5-dev \
libqwt-qt5-dev \
libspatialindex-dev \
libspatialite-dev \
libsqlite3-dev \
libsqlite3-mod-spatialite \
libyaml-tiny-perl \
libzip-dev \
libzstd-dev \
lighttpd \
locales \
ninja-build \
ocl-icd-opencl-dev \
opencl-headers \
pdal \
pkg-config \
poppler-utils \
protobuf-compiler \
pyqt5-dev \
pyqt5-dev-tools \
pyqt5.qsci-dev \
python3-all-dev \
python3-autopep8 \
python3-dateutil \
python3-dev \
python3-future \
python3-gdal \
python3-httplib2 \
python3-jinja2 \
python3-lxml \
python3-markupsafe \
python3-mock \
python3-nose2 \
python3-owslib \
python3-plotly \
python3-psycopg2 \
python3-pygments \
python3-pyproj \
python3-pyqt5 \
python3-pyqt5.qsci \
python3-pyqt5.qtsql \
python3-pyqt5.qtsvg \
python3-pyqt5.qtwebkit \
python3-requests \
python3-sip \
python3-sip-dev \
python3-six \
python3-termcolor \
python3-tz \
python3-yaml \
qt3d-assimpsceneimport-plugin \
qt3d-defaultgeometryloader-plugin \
qt3d-gltfsceneio-plugin \
qt3d-scene2d-plugin \
qt3d5-dev \
qt5-default \
qt5keychain-dev \
qtbase5-dev \
qtbase5-private-dev \
qtmultimedia5-dev \
qtpositioning5-dev \
qttools5-dev \
qttools5-dev-tools \
saga \
spawn-fcgi \
xauth \
xfonts-100dpi \
xfonts-75dpi \
xfonts-base \
xfonts-scalable \
xvfb
开始编译
将源码包 QGIS-final-3_34_13.tar.gz 放入工作目录解压
tar -zxf QGIS-final-3_34_13.tar.gz
cd QGIS-final-3_34_13
mkdir build-master
cd build-master
ccmake ..
开启ccmake界面后 按c configure完成后 按g 生成makefile文件
输入 make
开始编译 编译时间较长, 耐心等候
注意:每次出现问题需重新编译时 需要删除掉 build-master目录下的所有文件(之前的编译缓存) 不然会有意想不到的错误。
编译完成后运行 ./output/bin/qgis 打开编译好的qgis 出现启动界面完成
加速方案
cmake自定义编译选项
cmake ..\-GNinja \-DCMAKE_BUILD_TYPE=RelWithDebInfo \-DQt5_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5 \-DUSE_CCACHE=ON \-DBUILD_WITH_QT6=OFF \-DWITH_DESKTOP=ON \-DWITH_ANALYSIS=ON \-DWITH_GUI=ON \-DWITH_QUICK=OFF \-DWITH_3D=OFF \-DWITH_GRASS7=OFF \-DWITH_GRASS8=OFF \-DSUPPRESS_QT_WARNINGS=ON \-DENABLE_TESTS=OFF \-DENABLE_MODELTEST=OFF \-DWITH_HANA=OFF \-DWITH_QGIS_PROCESS=OFF \-DWITH_QSPATIALITE=ON \-DWITH_QWTPOLAR=OFF \-DWITH_APIDOC=OFF \-DWITH_ASTYLE=OFF \-DWITH_BINDINGS=OFF \-DWITH_SERVER=OFF \-DWITH_SERVER_LANDINGPAGE_WEBAPP=OFF \-DWITH_ORACLE=OFF \-DWITH_PDAL=OFF \-DWITH_QTSERIALPORT=ON \-DWITH_QTWEBKIT=OFF \-DDISABLE_DEPRECATED=ON \-DAGGRESSIVE_SAFE_MODE=ON
然后
sudo ninja
sudo ninja install
问题和解决方案
- geos版本过低
mkdir build-geos
cd build-geos
wget https://download.osgeo.org/geos/geos-3.13.0.tar.bz2
tar -C . -xjf geos-3.13.0.tar.bz2cmake -G Ninja \-D CMAKE_BUILD_TYPE=Release \./geos-3.13.0ninja
sudo ninja install
- libdraco-dev没找到
mkdir build-draco
cd build-draco
wget -O draco-1.5.7.tar.gz https://github.com/google/draco/archive/refs/tags/1.5.7.tar.gz
tar -C . -xzf draco-1.5.7.tar.gzcmake -G Ninja \-D CMAKE_BUILD_TYPE=Release \./draco-1.5.7ninja
sudo ninja install
python找不到
sudo apt install python3.9
moc没有权限
sudo setstatus Softmode