10、安裝mysql支持
安裝fedora15或者16系統時若選擇安裝mysql數據庫,則必須自行安裝mysql開發包。因為自帶默認數據庫不會安裝這個包。否則會遇到mysql錯誤:
ogr_mysql.h:34:23: fatal error: my_global.h: No such file or directory
#問題原因:找不到mysql頭文件,系統默認安裝的mysql不含開發包。 #解決辦法:使用yum源安裝mysql++-devel即可。 yum install mysql++-devel
11、配置安裝GDAL,使其支持[expat、libkml、hdf4/5、mysql、netcdf、ECW] [DWG/DXF暫時不支持,非開源]
下載地址:http://trac.osgeo.org/gdal/wiki/DownloadSource
(1)創建安裝目錄:
mkdir /usr/local/gdal190
(2)配置和依賴檢查
./configure --prefix=/usr/local/gdal190 --with-mysql=/usr/bin/mysql_config --with-libkml=/usr/local/libkml130 --with-expat=/usr/local/expat201 --with-hdf4=/usr/local/hdf427 --with-hdf5=/usr/local/hdf5188 --with-netcdf=/usr/local/netcdf413 --with-ecw=/usr/local/libecwj233
可見到結果如下:
GDAL is now configured for x86_64-unknown-linux-gnu Installation directory: /usr/local/gdal190 C compiler: gcc -g -O2 C++ compiler: g++ -g -O2 LIBTOOL support: yes LIBZ support: external LIBLZMA support: no GRASS support: no CFITSIO support: no PCRaster support: internal LIBPNG support: internal GTA support: no LIBTIFF support: internal (BigTIFF=yes) LIBGEOTIFF support: internal LIBJPEG support: internal 8/12 bit JPEG TIFF: yes LIBGIF support: internal OGDI support: no HDF4 support: yes HDF5 support: yes NetCDF support: yes Kakadu support: no JasPer support: no OpenJPEG support: no ECW support: yes MrSID support: no MrSID/MG4 Lidar support: no MSG support: no GRIB support: yes EPSILON support: no WebP support: no cURL support (wms/wcs/...):yes PostgreSQL support: no MySQL support: yes Ingres support: no Xerces-C support: no NAS support: no Expat support: yes Google libkml support: yes ODBC support: no PGeo support: no FGDB support: no MDB support: no PCIDSK support: internal OCI support: no GEORASTER support: no SDE support: no Rasdaman support: no DODS support: no SQLite support: no SpatiaLite support: no DWGdirect support no INFORMIX DataBlade support:no GEOS support: no VFK support: yes Poppler support: no Podofo support: no OpenCL support: no Armadillo support: no FreeXL support: no SWIG Bindings: no Statically link PROJ.4: no enable OGR building: yes enable pthread support: yes enable POSIX iconv support:yes hide internal symbols: no
可以見到我們要求的幾個庫都已是yes狀態,下一步就是編譯和安裝。
(3)編譯
#編譯,默認為-O2 make
可能會遇到的問題:
(3-1)可能遇到錯誤:
/local/libpthread.so.0: could not read symbols: Invalid operation /usr/bin/ld: /usr/local/libecwj233/lib/libNCSUtil.so.0: undefined reference to symbol 'pthread_cancel@@GLIBC_2.2.5' /usr/bin/ld: note: 'pthread_cancel@@GLIBC_2.2.5' is defined in DSO /local/libpthread.so.0 so try adding it to the linker command line
問題原因(DSO編譯問題):
ECW庫文件libNCSUtil.so.0中引用的符號“pthread_cancel@@GLIBC_2.2.5”被定義在libpthread.so.0庫中,link接到前者時必須在命令行中同時link到后者。
詳細可見這里:https://fedoraproject.org/wiki/UnderstandingDSOLinkChange和http://hi.baidu.com/operationsystem/blog/item/eed58d2e91e298291e3089cc.html
解決辦法:修改configure文件。
vi configure #找到所有的“-lNCSUtil”,在其后添加“-/local/libpthread.so.0”。 #例如:將LIBS="-lNCSEcw -lNCSCnet -lNCSUtil $LIBS",修改為LIBS="-lNCSEcw -lNCSCnet -lNCSUtil -/local/libpthread.so.0 $LIBS" #重新運行(2)、(5),發現Google libkml support變成了 no,百思不得其解,重新安裝libkml也無濟於事。。。
不得已將libkml和gdal全部刪除,重新安裝,進行到上面一步時依舊出現問題(3-1):
#出現錯誤: /local/libpthread.so.0: could not read symbols: Invalid operation #按照10-(3-1)中的方法對configure文件進行修改,同樣遇到google libkml support變為no的問題。
考慮將configure改回,卻發現google libkml support又變成了yes,由此可以想到(3-1)所遇到問題均是由此而來。又做了幾個嘗試,取得成功:
#修改configure文件: vi configure #嘗試1、找到-lNCSUtil,在其后添加"-l/local/libpthread.so.0",失敗。 #嘗試2、找到-lNCSUtil,在其后添加"-l/local/libpthread.so.0",失敗。 #嘗試3、找到-lNCSUtil,在其后添加“-lpthread”,失敗。 #嘗試4、找到-lNCSUtil,在其后添加“-lpthread”,修改/etc/ld.so.conf,在最后將libpthread.so.0所在目錄(/local)加上,運行ldconfig命令,成功。
(3-2)可能遇到mysql錯誤:
#遇到mysql錯誤: ogr_mysql.h:34:23: fatal error: my_global.h: No such file or directory #問題原因:找不到mysql頭文件,系統默認安裝的mysql不含開發包。 #解決辦法:使用yum源安裝mysql++-devel即可。 yum install mysql++-devel
(3-3)可能遇到另一種形式的mysql錯誤:
/usr/bin/ld: cannot find -lmysqlclient collect2: ld returned 1 exit status make[1]: *** [libgdal.la] Error 1 make[1]: Leaving directory `/home/geohpc/gdal/gdal-1.9.0--fanjf-edited' make: *** [check-lib] Error 2 #原因:找不到libmysqlclient庫,原因是沒有安裝mysql-devel包
在rmpfind網站上下載后安裝即可
[root@geohpc geohpc]# rpm -i mysql-devel-5.5.10-2.fc15.x86_64.rpm [root@geohpc geohpc]# rpm -qa mysql-devel mysql-devel-5.5.10-2.fc15.x86_64
(4)重新編譯
make clean
make
(5)安裝
make install
完成安裝。
連載完。
全部為本人辛苦勞動,請尊重作者,轉載請注明出處!!!