Last active
May 27, 2024 12:03
-
-
Save zty5678/7cb8372e5cbfae1f3c152d62986f0f02 to your computer and use it in GitHub Desktop.
Mac 编译 java 版本 gdal 3.8.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
参考博客:https://www.cnblogs.com/echohye/p/17580078.html | |
1. 下载源码 | |
version=3.8.3 | |
wget http://download.osgeo.org/gdal/$version/gdal-$version.tar.xz | |
2. 编译。解压,执行: | |
cmake -S . -B build \ | |
-DCMAKE_INSTALL_RPATH=/opt/gdal \ | |
-DBUILD_JAVA_BINDINGS=ON \ | |
-DCMAKE_INSTALL_PREFIX=/opt/gdal \ | |
-DCMAKE_INSTALL_LIBDIR=/opt/gdal \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_VERBOSE_MAKEFILE=ON \ | |
-Wno-dev \ | |
-DBUILD_TESTING=OFF | |
这一步会报错,提示: | |
Buildfile: /Users/xxxx/Downloads/temp3/gdal-3.8.3/swig/java/build.xml | |
init: | |
[echo] version = 3.8.3 | |
compile: | |
[mkdir] Created dir: /Users/xxxx/Downloads/temp3/gdal-3.8.3/build/swig/java/build/classes | |
[javac] Compiling 88 source files to /Users/xxxx/Downloads/temp3/gdal-3.8.3/build/swig/java/build/classes | |
[javac] 警告: [options] 未与 -source 7 一起设置引导类路径 | |
[javac] 错误: 不再支持源选项 7。请使用 8 或更高版本。 | |
[javac] 错误: 不再支持目标选项 7。请使用 8 或更高版本。 | |
BUILD FAILED | |
/Users/xxxx/Downloads/temp3/gdal-3.8.3/swig/java/build.xml:25: Compile failed; see the compiler error output for details. | |
3. 修正编译错误 | |
这时候只需要修改下/Users/xxxx/Downloads/temp3/gdal-3.8.3/swig/java/build.xml: | |
将里面的两处 source="7" target="7" 改为 source="8" target="8" 即可。 | |
4. 安装。 | |
然后安装库:cmake --build build | |
如果有权限问题,就加sudo。 | |
5. 拷贝产物。 | |
最后再把 /opt/gdal/jni下的 libgdalalljni.dylib 复制到/Library/Java/Extensions里就行了。 | |
可能还需要把 /opt/gdal/下的libgdal.dylib 等文件也复制过去 |
如果有GTIFF相关的报错, 那么再加上 -DGDAL_USE_GEOTIFF_INTERNAL=ON
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cmake -S . -B build
-DCMAKE_INSTALL_RPATH=/opt/gdal
-DBUILD_JAVA_BINDINGS=ON
-DCMAKE_INSTALL_PREFIX=/opt/gdal
-DCMAKE_INSTALL_LIBDIR=/opt/gdal
-DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON
-DCMAKE_BUILD_TYPE=Release
-DGDAL_USE_LIBKML=OFF
-DCMAKE_VERBOSE_MAKEFILE=ON
-Wno-dev
-DBUILD_TESTING=OFF