GEOS / GDAL ARM64-linux cross compiler version

Because the trial Huawei cloud ARM64 server, the server in the cloud for a long time to compile GDAL has not compiled, so the first version of the cross-compiler for GDAL throw on to do the test.
The following are carried out under CentOS 7 x86_64 environment, Linux kernel version 3.10.

Installation compilation environment

1, download and install the compiler

# 这里可以去 https://developer.arm.com/tools-and-software/ 网站找
# 注意:要安装arm-none-linux-gnueabi-gcc,这个是编译linux程序的
# 不能安装arm-none-abi-gcc版本,这个是针对裸机程序的
wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz
# 上面地址是小端序的,大端序版本地址: https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64_be-linux-gnu.tar.xz

# 解压
tar -xJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C /opt/gcc-arm-8.3-x86_64-aarch64-linux
# 导入环境变量中去
export PATH=${PATH}:/opt/gcc-arm-8.3-x86_64-aarch64-linux

Compile PROJ.4

git clone -b 4.9 --depth 1 https://github.com/OSGeo/PROJ.git proj.4
# 因为configure默认设置CC为gcc,所以这边必须先设置
export CC=aarch-linux-gun-gcc
export CC=aarch-linux-gun-gcc
# 生成Makefile
./configure --build=x86_64-pc-linux-gnu --host=aarch64-linux --target=aarch64-linux  --prefix=/home/test/arm64/install
# 编译安装
make && make install
# 查看下编译的对不对
file src/.libs/libproj.so.0.8.0                                                                   src/.libs/libproj.so.0.8.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, not stripped

Compile GEOS

# 我这里只是需要编译一下,就不克隆全部了
git clone -b svn-3.6 --depth 1 https://github.com/libgeos/geos.git

mkdir geos/build && cd geos/build

# 执行cmake,生成Makefile。指定使用的编译器和查找头文件和库文件的根目录
# 参考 CMake设置arm-linux-gcc交叉编译器 https://www.cnblogs.com/rickyk/p/3875334.html
cmake3 .. -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_FIND_ROOT_PATH=/opt/gcc-arm-8.3-x86_64-aarch64-linux -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_INSTALL_PREFIX=/home/test/arm64/install
# 编译
make && make install
# 查看下编译的对不对
file lib/libgeos_c.so.1.10.4
lib/libgeos_c.so.1.10.4: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, not stripped

Compile GDAL

git clone -b v2.4.0 --depth 1 https://github.com/OSGeo/gdal.git
cd gdal/gdal
# 生成Makefile(实际是GDALMake.opt)
./configure --build=x86_64-pc-linux-gnu --host=aarch64-linux --target=aarch64-linux  --prefix=/home/test/arm64/install
# 开始我添加 --with-geos=./geos-config(这个脚本在geos的编译目录下的tools目录中),结果还是没有用
#   只能运行完成之后打开GDALmake.opt文件进行修改
#   找到 GEOS Suport 和 PROJ.4 stuff 位置,修改内容入下面的图中所示
# 然后对 apps/GNUmakefile 文件也进行修改
#   把其中的 LNK_FLAGS 变量中追加 $(LIBS)

# 编译安装
make && make install

GDALmake.optapps/GNUmakefile

Guess you like

Origin www.cnblogs.com/oloroso/p/11129708.html