当前位置:   article > 正文

qgis库linux环境下编译_qgis linux源代码

qgis linux源代码

RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
RES=$(tput sgr0) #清除颜色

function pause()
{
	echo "${RED}Press any key to continue!${RES}"
	
	dd if=/dev/tty bs=1 count=1 2> /dev/null
} 

function open_package()
{
	tar_dir=$1  #压缩包路径
	src_dir=$2
	run_cmd=$3
	#解压	
	if [ ! -d ./build_env/${src_dir} ] ; then	
		echo "tar package $tar_dir"
		tar -xf ${tar_dir} -C ./build_env/
	fi
	# 执行操作
	$run_cmd
}

function build_proj()
{
	pkg_type=$1 #安装包名称
	tar_dir=$2  #压缩包路径
	src_dir=$3  #configure路径
	ex_config=$4 #congfiure扩展
	make_config=$5
	#安装路径
	prefix_dir=/home/$USER/qgis_libs/${pkg_type}
		
	echo $pkg_type---$tar_dir----$src_dir----$ex_config---$make_config
	
	#判断 已安装 文件夹
	if [ ! -d ${prefix_dir} ] ; then
		#解压	
		if [ ! -d ./build_env/${src_dir} ] ; then	
			tar -xf tars/${tar_dir} -C ./build_env/
		fi
		
		TEMPPWD=$PWD
		
		cd ./build_env/${src_dir}/
		./configure --prefix=${prefix_dir} ${ex_config}
		make -j4 $make_config
		make -j4 install $make_config
		
		cd $TEMPPWD
	fi
	
	# 不存在 安装 文件夹
	if [ ! -d ${prefix_dir} ] ; then
		pause 		 
	fi 
	
	#环境变量
	export PATH=$PATH:${prefix_dir}/bin
	export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${prefix_dir}/lib/pkgconfig
	export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${prefix_dir}/lib
	
	echo "${GREEN} ${pkg_type} ok ${RES}"
}

function cmake_proj()
{
	pkg_type=$1 #安装包名称	
	src_dir=$2  #configure路径
	ex_config=$3 #congfiure扩展
	make_config=$4
	
	echo $pkg_type---$src_dir---$ex_config--$make_config
	
	#安装路径
	prefix_dir=/home/$USER/qgis_libs/${pkg_type}
	
		#判断 已安装 文件夹
	if [ ! -d ${prefix_dir} ] ; then	
		
		TEMPPWD=$PWD
		
		cd  ${src_dir}		
		#源码位置
		/home/$USER/cmake-3.13.2/bin/cmake -S $PWD -B ./mybuild/  -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${prefix_dir}  ${ex_config}
		cd ./mybuild/ 
		make -j4 $make_config
		make -j4 install $make_config
		
		cd $TEMPPWD
	fi 
	
	# 不存在 安装 文件夹
	if [ ! -d ${prefix_dir} ] ; then
		pause 		 
	fi 
	
	#环境变量
	export PATH=$PATH:${prefix_dir}/bin
	export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${prefix_dir}/lib/pkgconfig
	export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${prefix_dir}/lib
	
	echo "${GREEN} ${pkg_type} ok ${RES}"
}

######################################
######################################
######################################
mkdir ./build_env

#libxm 
build_proj libxml2 libxml2-2.7.8.tar.gz libxml2-2.7.8
#freexl 
build_proj freexl freexl_1.0.5.orig.tar.gz freexl-1.0.5

# #zlib 
build_proj zlib zlib-1.2.11.tar.gz zlib-1.2.11

#sqlite3
# /usr/lib/x86_64-linux-gnu/
# build_proj tcl envs/tcl8.6.13-src.tar.gz tcl8.6.13/unix
# mkdir ./build_env/sqlite-amalgamation-3150100
# cmake_proj sqlite3 sqlite-amalgamation-3150100 


#libiconv  ### gets error 处理
open_package ./tars/libiconv-1.14.tar.gz libiconv-1.14
sed -i -e '/gets is a security/d' ./build_env/libiconv-1.14/srclib/stdio.in.h
build_proj libiconv libiconv-1.14.tar.gz libiconv-1.14

#geos 
build_proj geos geos-3.5.0.tar.bz2 geos-3.5.0

#proj
build_proj proj proj-4.9.3.tar.gz proj-4.9.3

#libspatialite 依赖 sqlite3/zlib/freexl/libiconv/proj/geos/libxml2
#proj_api.h not found
export CPPFLAGS="-I/home/$USER/qgis_libs/proj/include -I/home/$USER/qgis_libs/freexl/include -I/home/$USER/qgis_libs/libxml2/include/libxml2 -I/home/$USER/qgis_libs/geos/include"
export LDFLAGS="-L/home/$USER/qgis_libs/proj/lib -L/home/$USER/qgis_libs/freexl/lib -L/home/$USER/qgis_libs/geos/lib"
build_proj libspatialite libspatialite-4.3.0.tar.gz libspatialite-4.3.0 "--with-pic"

#gdal 依赖
build_proj gdal gdal-2.2.0.tar.gz gdal-2.2.0/gdal  "--with-proj=~/qgis_libs/proj --with-geos=~/qgis_libs/geos" 

#spatialindex
build_proj spatialindex spatialindex-src-1.8.0.tar.gz spatialindex-src-1.8.0

#libexpat 
open_package ./tars/libexpat-R_2_1_0.tar.gz libexpat-R_2_1_0
cmake_proj libexpat build_env/libexpat-R_2_1_0/expat "-DBUILD_tools=OFF"

##### QT 工程 ########
MY_QT_PATH=~/3rd_party/qt
#qca 
open_package ./tars/qca-2.1.3.tar.xz qca-2.1.3
cmake_proj qca ./build_env/qca-2.1.3 "-DCMAKE_PREFIX_PATH=$MY_QT_PATH -DBUILD_TESTS=OFF"
#qscintilla
open_package ./tars/qscintilla-2.10.8.tar.gz qscintilla-2.10.8
cp ./myconfigs/qscintilla/CMakeLists.txt ./build_env/qscintilla-2.10.8/Qt4Qt5/CMakeLists.txt
cmake_proj qscintilla ./build_env/qscintilla-2.10.8/Qt4Qt5 "-DCMAKE_PREFIX_PATH=$MY_QT_PATH -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON"
#qwt
open_package ./tars/qwt-6.1.2.tar.bz2 qwt-6.1.2
cp ./myconfigs/qwt/CMakeLists.txt ./build_env/qwt-6.1.2/CMakeLists.txt
cmake_proj qwt ./build_env/qwt-6.1.2 "-DCMAKE_PREFIX_PATH=$MY_QT_PATH"

######### QGIS #######
#
export PATH=$PATH:~/3rd_party/m4-1.4.18/bin	
export PATH=$PATH:~/3rd_party/flex-2.6.4/bin	
export PATH=$PATH:~/3rd_party/bison-2.7/bin	
#解压文件
open_package ./tars/QGIS-final-2_18_0.tar.gz QGIS-final-2_18_0
# expat.h not found 
export CPLUS_INCLUDE_PATH="/home/$USER/qgis_libs/libexpat/include"
# invalid use of incomplete type *** #第N行添加include
sed -i '52s/.*/#include <QButtonGroup>/g' ./build_env/QGIS-final-2_18_0/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
sed -i '29s/.*/#include <QHeaderView>/g' ./build_env/QGIS-final-2_18_0/src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp
sed -i '27s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
sed -i '30s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/wms/qgswmsdataitems.cpp
sed -i '32s/.*/#include <QHeaderView>/g' ./build_env/QGIS-final-2_18_0/src/gui/qgscompoundcolorwidget.cpp
sed -i '19s/.*/#include <QDoubleValidator>/g' ./build_env/QGIS-final-2_18_0/src/gui/qgsextentgroupbox.cpp
sed -i '18s/.*/#include <QValidator>/g' ./build_env/QGIS-final-2_18_0/src/gui/qgsgroupwmsdatadialog.cpp
sed -i '36s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/gui/qgsmaptoolcapture.cpp
sed -i '39s/.*/#include <QButtonGroup>/g' ./build_env/QGIS-final-2_18_0/src/gui/qgssourceselectdialog.cpp
sed -i '26s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/ows/qgsowsdataitems.cpp
sed -i '27s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/wcs/qgswcsdataitems.cpp
sed -i '35s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/mssql/qgsmssqldataitems.cpp
sed -i '28s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/wfs/qgswfsdataitems.cpp
sed -i '32s/.*/#include <QAction>/g' ./build_env/QGIS-final-2_18_0/src/providers/db2/qgsdb2dataitems.cpp
#find_package查询路径设置
MY_QGIS_ENV_PATH="$MY_QT_PATH;~/qgis_libs/qca;~/qgis_libs/libexpat;~/qgis_libs/proj;~/qgis_libs/qscintilla;~/qgis_libs/qwt;~/qgis_libs/spatialindex;~/qgis_libs/libspatialite"
cmake_proj qgis ./build_env/QGIS-final-2_18_0 "-DCMAKE_PREFIX_PATH=$MY_QGIS_ENV_PATH -DWITH_BINDINGS=OFF -DWITH_QTWEBKIT=OFF -DENABLE_QT5=ON -WITH_GRASS=FALSE -DWITH_POSTGRESQL=FALSE -DENABLE_TESTS=FALSE -DWITH_DESKTOP=FALSE"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/117518
推荐阅读
相关标签
  

闽ICP备14008679号