ANDROID-GDAL 交叉编译

来源:互联网 发布:可信的淘宝货源 编辑:程序博客网 时间:2024/06/05 02:09
需要准备的东西:GDAL下载(我的是2.1.1) ANDROID-NDK-R10E 以及cygwin
1 打开cygwin终端在命令行,找到NDK下面build/tool/make-standalone-toolchain.sh文件
2 创建工具链 输入如下命令:
arm64: ./make-standalone-toolchain.sh --toolchain=aarch64-linux-android-4.9 arch=arm64 --platform=android-21 
--system=windows-x86_64-ndk-dir=/cygwin/d/android/android-ndk-r10e --install-dir=/cygdrive/d/android/toolchain-21-arch64
----------------------------
armeabi-v7a:   ./make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.9  arch=arm --platform=android-15 --system=windows-x86_64 --install-dir=/cygdrive/d/android/android-toolchain-15-armv7 --ndk-dir=//cygdrive/d/android/android-ndk-r10e
3  创建工具链之后将创建的工具链的路径加入PATH环境变量如:/cygdrive/d/android/android-toolchain-21-armv7/bin加入到系统环境变量
4 执行configure(注意输出里面的文字内容,里面有个是否是交叉编译的信息输出[checking whether we are cross compiling... yes] 如果是YES 说明是正确的,否则就要小心了,编译处理来的就有问题)
arm64下面的configureLIBS="-lstdc++"./configure--prefix=d:/android/pp--with-threads--with-ogr --host=aarch64-linux-android --without-geos--with-libz=internal -without-libtool -with-oci=no--with-xerces=no --with-expat=no --with-libkml=no --without-jpeg12 --without-bsb --without-grib --without-openfilegdb --without--filegdb --without-pam --without-pdf --without-sentinel2 --without-ctg --without-kmlsuperoverlay--without-wcs --without-vdv --without-dgn --without-dwg
armeabi-v7a下面的configure
CFLAGS="-mthumb" CXXFLAGS="-mthumb" LIBS="-lstdc++" ./configure --prefix=d:/android/pp1 --with-threads --with-ogr --host=arm-linux-androideabi  --without-geos --with-libz=internal -without-libtool -with-oci=no --with-xerces=no --with-expat=no --with-libkml=no --without-jpeg12 --without-bsb --without-grib --without-openfilegdb --without--filegdb --without-pam  --without-pdf --without-sentinel2 --without-ctg --without-kmlsuperoverlay --without-wcs --without-vdv --without-dgn --without-dwg
---------------------------------------------
5 make 
执行MAKE之后可能会出现找不到cpl_port.h头文件找不到问题,这个是由于使用的路径是linux下面的路径,将Gdal根目录下面的GDALmake.opt中增加一个GDAL_ROOT_PATH的路径,
里面有头文件包含的地方以及动态连接库的地方(可以在编译出错的时候改)都用GDAL_ROOT_PATH这个代替GDAL_ROOT  
其中GDAL_ROOT_PATH这个是windows下面的路径(路径是反斜杠的)。
有些时候会出现Error : *** target pattern contains no `%' 这个问题是因为CYGWIN的版本有问题,将cygwin/bin下面的make文件改成make.exe改成3.8版本的(具体可以在网上找这个文件,主要原始是不识别路径中的“:”)
执行完成之后 生成的静态库大概是170M
make install