Linux18.04安装GDAL2.0.0

Linux18.04安装GDAL2.0.0 gdalserver.c编译失败的问题

1.下载GDAL源代码

下载源码链接:http://download.osgeo.org/gdal/
官方提供的安装方法:https://trac.osgeo.org/gdal/wiki/BuildingOnUnix

我自己的理解是安装GDAL前需要一些前置的库,但是官方文档并没有对此给出详细说明。我安装了proj和geos,分别是proj4.9.2、geos3.5.2。

geos下载链接:https://libgeos.org/usage/download/
proj下载链接:http://download.osgeo.org/proj/

这两个安装方式和GDAL一样。./configure 这一步,后面不用加东西,默认路径就行。

2.make步骤gdalserver.c编译出问题

gdalserver.c: In function 'CreateSocketAndBindAndListen':
gdalserver.c:124:21: error: storage size of 'sHints' isn't known
     struct addrinfo sHints;
                     ^~~~~~
gdalserver.c:126:31: error: invalid application of 'sizeof' to incomplete type 'struct addrinfo'
     memset(&sHints, 0, sizeof(struct addrinfo));
                               ^~~~~~
gdalserver.c:129:23: error: 'AI_PASSIVE' undeclared (first use in this function); did you mean 'AF_WANPIPE'?
     sHints.ai_flags = AI_PASSIVE;
                       ^~~~~~~~~~
                       AF_WANPIPE
gdalserver.c:129:23: note: each undeclared identifier is reported only once for each function it appears in
gdalserver.c:132:12: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
     nRet = getaddrinfo(NULL, pszService, &sHints, &psResults);
            ^~~~~~~~~~~
gdalserver.c:135:48: warning: implicit declaration of function 'gai_strerror'; did you mean 'strerror'? [-Wimplicit-function-declaration]
         fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(nRet));
                                                ^~~~~~~~~~~~
                                                strerror
gdalserver.c:135:42: warning: format '%s' expects argument of type 'char ', but argument 3 has type 'int' [-Wformat=]
         fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(nRet));
                                         ~^     ~~~~~~~~~~~~~~~~~~
                                         %d
gdalserver.c:141:39: error: dereferencing pointer to incomplete type 'struct addrinfo'
          psResultsIter = psResultsIter->ai_next)
                                       ^~
gdalserver.c:162:5: warning: implicit declaration of function 'freeaddrinfo' [-Wimplicit-function-declaration]
     freeaddrinfo(psResults);
     ^~~~~~~~~~~~
gdalserver.c:124:21: warning: unused variable 'sHints' [-Wunused-variable]
     struct addrinfo sHints;
                     ^~~~~~

查阅资料后,在官方文档查到同样的错误,https://trac.osgeo.org/gdal/ticket/6073#no1
修改方法是 gdal-2.0.0/apps/gdalserver.c 中
#define _XOPEN_SOURCE 修改成
#define _XOPEN_SOURCE 600
修改之后再正常安装就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值