zoukankan      html  css  js  c++  java
  • linux下编译GDAL外加扩展格式支持(五)完

    1234篇。

    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,使其支持[expatlibkmlhdf4/5、mysql、netcdfECW] [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/UnderstandingDSOLinkChangehttp://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

    完成安装。

    连载完。

    全部为本人辛苦劳动,请尊重作者,转载请注明出处!!!

     

  • 相关阅读:
    记录阿里云服务器mysql被黑
    微服务SpringCloud容器化案例
    优雅的启动、停止、重启你的SpringBoot项目
    java模式:建造者模式
    java集合 线程安全
    挖坑:hive集成kerberos
    挖坑:handoop2.6 开启kerberos(全流程学习记录)
    Specified version of key is not available (44)
    Mysql数据按天分区,定期删除
    maven项目打包额外lib目录
  • 原文地址:https://www.cnblogs.com/yeahgis/p/2446742.html
Copyright © 2011-2022 走看看