【问题标题】:Cross Compiling ghostscript for android, what host should I use?为android交叉编译ghostscript,我应该使用什么主机?
【发布时间】:2016-05-27 08:26:00
【问题描述】:

大家好,我正在使用this 教程构建 ghostscript-9.19,以便能够在我的 android 应用程序中使用将 eps 文档转换为 pdf。配置时失败。这是日志

checking whether to enable maintainer-specific portions of Makefiles...
no
checking for gcc... arm-linux-androideabi-gcc -- 
sysroot=/<path>/android-ndk-   
r11c/platforms/android-17/arch-arm/
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in    
`/<path>/ghostscript-9.19/tiff-config':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
configure: error: libtiff configure script failed

这是我正在运行的构建文件

#!/bin/sh
# Compiles ghostscript for Android
# Make sure you have NDK_ROOT defined in .bashrc or .bash_profile

INSTALL_DIR="`pwd`/app/jni/gs"
SRC_DIR="`pwd`/../ghostscript-9.19"

cd $SRC_DIR

export
PATH="/<path>/android-ndk-r11c/toolchains/arm-        
linux-androideabi-4.9/prebuilt/darwin-x86_64/bin:$PATH"
export SYS_ROOT="/<path>/Android/android-ndk-
r11c/platforms/android-17/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"

mkdir -p $INSTALL_DIR
./configure --host=arm-linux-androideabi --build=x86_64-apple-darwin
--prefix=$INSTALL_DIR LIBS="-lc -lgcc"

make PREFIX=$INSTALL_DIR
make install DESTDIR=$INSTALL_DIR

exit 0

我正在使用 --host=arm-linux-androideabi。我应该使用什么主机?我需要在 ghostScript 项目中进行哪些更改才能成功编译? 非常感谢任何帮助。

【问题讨论】:

  • 你最终能解决你的ghostscript和android问题吗? PIE 问题似乎是在编译标志中添加 -fPIC 的问题。
  • 是的,我能够解决问题。我编译了解决方案中提到的提交。

标签: android android-ndk java-native-interface ghostscript


【解决方案1】:

交叉编译 Ghostscript 相当复杂,部分原因是 Ghostscript 构建依赖于构建和运行临时工具(genarch、genconf、mkromfs 和 echogs),这些工具显然必须使用本机编译器而不是交叉编译器来构建。

我认为您看到的问题是因为对 libtiff 配置的调用没有传递所需的选项。

从这个提交中抓取和调整两个文件(makefile 和 header)可能会更好: Makefile for Android MuPDF libgs.so

并对其进行调整以符合您的要求。

在本页底部有一个关于如何进行交叉编译的基本指南: Ghostscript FAQ

我有一个“项目”来改进对交叉编译的支持,但目前进展缓慢。

【讨论】:

  • 非常感谢您的帮助。它就像一个魅力,我可以在我的 android 应用程序中使用 ghostscript。
  • 你有机会分享你完成的 GhostScript 库吗?
  • @chrisl 我又遇到麻烦了。我从上面得到的 gs 二进制文件在 Android 6.0.1 上不起作用,给出错误“仅支持与位置无关的可执行文件 (PIE)。”。由于我只使用了make文件,我无法制作gs PIE。我已经看了很多来修复它,但没有奏效。我什至在我的手机上尝试了 bypass-pie.zip。没运气。有什么可以提供的帮助吗?
  • @chrisl,你有计划转向更现代的构建工具吗?我尝试为 ghostscript 创建 CMakeLists.txt:genarch 可以用 try_run() 转换,gconfig_h 可以用 configure() 实现,mkromfs 可以用 try_compile() 和后续执行来实现。我停止了 genconf 所需的生成步骤,我不太了解,因为害怕无法生成有效的二进制文件。在这次尝试之后,我估计(对我而言)需要 2 周的全职任务来生产一些有用的东西,但这似乎完全可行,并且会大大简化构建系统。
  • 不,我们绝对不会尝试迁移到 CMake。
猜你喜欢
  • 2022-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多