作者:朱金灿
来源:clever101的专栏
在uos(华为鲲鹏服务器,arm架构cpu)编译gdal3.12时出现下面错误:
/bin/bash /home/ThirdPartySrc/gdal-3.1.2/libtool --mode=link --silent g++ gdalinfo_bin.lo /home/ThirdPartySrc/gdal-3.1.2/libgdal.la -o gdalinfo
/usr/bin/ld: /home/ThirdPartySrc/gdal-3.1.2/.libs/libgdal.so: undefined reference to `png_riffle_palette_neon'
/usr/bin/ld: /home/ThirdPartySrc/gdal-3.1.2/.libs/libgdal.so: undefined reference to `png_do_expand_palette_rgb8_neon'
/usr/bin/ld: /home/ThirdPartySrc/gdal-3.1.2/.libs/libgdal.so: undefined reference to `png_init_filter_functions_neon'
/usr/bin/ld: /home/ThirdPartySrc/gdal-3.1.2/.libs/libgdal.so: undefined reference to `png_do_expand_palette_rgba8_neon'
collect2: error: ld returned 1 exit status
make[1]: *** [GNUmakefile:90:gdalinfo] 错误 1
make[1]: 离开目录“/home/ThirdPartySrc/gdal-3.1.2/apps”
make: *** [GNUmakefile:123:apps-target] 错误 2
可以看出这是在arm架构编译png驱动对某个预编译宏不兼容造成的,解决办法是在pngpriv.h中添加#define PNG_ARM_NEON_OPT 0,关闭对png_riffle_palette_neon函数的调用,如下:
#define PNG_ARM_NEON_OPT 0 // 添加的代码
#ifndef PNG_ARM_NEON_OPT
/* ARM NEON optimizations are being controlled by the compiler settings,
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
* with GCC) then the compiler will define __ARM_NEON__ and we can rely
* unconditionally on NEON instructions not crashing, otherwise we must
* disable use of NEON instructions.
*
* NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
* can only be turned on automatically if that is supported too. If
* PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
* off.
*
* Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
* __ARM_NEON__, so we check both variants.
*
* To disable ARM_NEON optimizations entirely, and skip compiling the
* associated assembler code, pass --enable-arm-neon=no to configure
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
*/
#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
#define PNG_ARM_NEON_OPT 2
#else
#define PNG_ARM_NEON_OPT 0
#endif
#endif
在华为鲲鹏服务器(uos,arm架构)上编译GDAL3.1.2时遇到链接错误,涉及png库中的NEON优化函数未定义。为解决此问题,需要在pngpriv.h中添加#definePNG_ARM_NEON_OPT0,禁用特定的NEON函数调用,以消除编译错误。

5934

被折叠的 条评论
为什么被折叠?



