1.QGIS源码下载[下载地址]
2.QGis编译依赖资源
所需的构建工具:
1.CMake >= 3.12.0下载
安装配置:
tar -xzvf cmake-3.28.0-rc1-linux-x86_64.tar.gz
mv cmake-3.28.0-rc1-linux-x86_64 /opt/cmake
ln -sf /opt/cmake/bin/* /usr/bin/查看是否成功
cmake --version
2.Flex >= 2.5.6下载
安装配置:
tar -xzvf flex-2.6.4.tar.gz
cd flex-2.6.4
./configure
make
make install查看是否成功
flex --version
3.Bison> = 2.4下载
安装配置:
tar -xzvf bison-2.3.tar.gz
cd bison-2.3
./configure
make
make install查看是否成功
bison --version
4.Python >= 3.7下载
安装配置:
tar -zxvf Python-3.12.0.tgz
mkdir /usr/local/Python37
cd Python-3.12.0
./configure --prefix=/usr/local/python37
makemake install
安装时报错ModuleNotFoundError: No module named '_ctypes’的解决办法:
yum install libffi-devel
创建软连接:ln -s /usr/local/python37/bin/python3.7 /usr/bin/python37
ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip37测试否可用
[root@mini Python-3.7.0]# python3
Python 3.7.0 (default, Jul 28 2018, 22:47:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>> exit()
所需的构建依赖项:
1.Qt >= 5.14.0下载
安装配置:
chmod 777 -R ./xxxxx.run
./xxxxx.run
注意需要配置qmake环境。执行 gedit /etc/profile
在文件末尾添加
export QTDIR=/opt/Qt5.14.2/5.14.2/gcc_64
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH执行 source /etc/profile
2.GEOS >= 3.9下载
安装配置:
tar -xvjf geos-3.12.1.tar.bz2
cd geos-3.12.1
./configure
make
make install
3.Sqlite3 >= 3.11下载
安装配置:
解压sqlite-src-3440000.zip
cd sqlite-src-3440000.
./configure
make
make install查看是否成功
sqlite3 -version
4.Proj >= 7.2.0下载
注:proj 依赖
SQLite3 >= 3.11 (上边已安装)
libtiff >= 4.0 下载安装配置:
解压 libtiff-master.zip
cd libtiff-master
cmake .
make
make installcurl >= 7.29.0下载
安装配置:
tar -xvf curl-8.4.0.tar.gz
cd curl-8.4.0
cmake .
make
make install
安装配置:
tar -xvf proj-9.2.1.tar.gz
cd proj-9.2.1
cmake .注:中间会下载 googletest-release-1.11.0.zip ,请将下载好的压缩包重命名成release-1.11.0.zip,并拷贝到 proj-9.2.1/googletest-download/googletest-prefix/src目录下(注意先将文件夹赋权限)
make
make install查看是否成功
proj -h
如果出现
proj: error while loading shared libraries: libtiff.so.6: cannot open shared object file: No such file or directory
执行以下建立软连接
ln -s /usr/local/lib/libtiff.so.6 /usr/lib/libtiff.so.6
5.SpatiaLite >= 4.2.0下载
安装配置:
tar -xzvf libspatialite-5.0.0.tar.gz
cd libspatialite-5.0.0
./configure
make
make install
查看是否成功
bison --version
6.libspatialindex下载
安装配置:
解压 libspatialindex-master.zip
cd libspatialindex-master
cmake .
make
make install
7.GDAL/OGR >= 3.2.0下载
add-apt-repository ppa:ubuntugis/ppa apt-get update apt-get install gdal-bin apt-get install libgdal-dev
安装配置:
tar -xzvf gdal-3.8.0.tar.gz
cd gdal-3.8.0
cmake .
make
make install
查看是否成功
gdal-config --version
编译出现以下错误
/gdal-3.1.1/.libs/libgdal.so: undefined reference to `sqlite3_column_origin_name'
/gdal-3.1.1/.libs/libgdal.so: undefined reference to `sqlite3_column_table_name'
具体做法是在sqlite3源码文件夹下
cd ./sqlite-autoconf-3320300
gedit ./sqlite3.c
添加
#define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE # define SQLITE_PRIVATE static #endif #define SQLITE_ENABLE_COLUMN_METADATA 1
然后重新编译sqlite3
8.Qwt >= 5.0 & (< 6.1 with internal QwtPolar)下载
安装配置:
解压 qwt-5.2.0.zip
cd qwt-5.2.0
qmake
make
make install
查看是否成功
qwt --h
9.expat >= 1.95下载
10.QScintilla2下载
安装配置:
tar -zxvf QScintilla_gpl-2.11.2.tar.gz
cd QScintilla_gpl-2.11.2/
cd ./Qt4Qt5
qmake qscintilla.pro
make
make install
.....
cd ../Python
python configure.py
make
sudo make install
11.QCA下载
12.qtkeychain (>= 0.5)下载
13.libzip下载
安装配置:
解压 libzip-main.zip
cd libzip-main
cmake .
make
make install查看是否成功
zip -h
10.安装pg Gem时找不到libpq-fe.h头文件***
对于Ubuntu系统:
sudo apt-get install libpq-dev
在Red Hat Linux(RHEL)系统上:
yum install postgresql-devel
对于Mac Homebrew:
brew install postgresql
对于Mac MacPorts PostgreSQL:
gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
对于OpenSuse:
zypper in postgresql-devel
12.安装sip (我用的版本是V4.19.14)
下载地址:https://riverbankcomputing.com/software/sip/download
sip -V检查版本
tar -zxvf sip-4.19.8.tar.gz
python3 configure.py --sip-module PyQt5.sip //必须添加这个,否则运行 import PyQt5.Core 会异常
sudo make -j8(或者你电脑的核心数)
sudo make install
安装完成后,可分别在终端和Python中查验sip版本是否一致
#终端查看sip版本
sip -V
#查看Python调用的sip版本(通过上述编译安装操作得到的)
python
import sip
print(sip.SIP_VERSION_STR)
13.安装PyQt (我用的版本是V4.11.3)
tar zxvf PyQt-gpl-5.3.2.tar.gz
cd PyQt-gpl-5.11.2/
python configure.py –qmake /opt/Qt5.11.1/5.3/gcc_64/bin/qmake –sip-incdir ../sip-4.19.4/siplib //也可以将qmke文件复制
到,/usr/bin/目录下,就不用添加-qmake
make -j4 //建议添加-j 要不然编译会很久
sudo make install
可设置创建软连接:
sudo ln -s /usr/lib/python3.4/site-packages/PyQt5 /usr/lib/python3.4/PyQt5
2.make进行编译
make -j8
make install
3.运行
1)当前目录直接运行
./output/bin/qgis
2)make安装运行
qgis