【问题标题】:How to build GLib for iOS如何为 iOS 构建 GLib
【发布时间】:2013-07-14 10:33:22
【问题描述】:

我想在我的 iOS 应用程序中使用 lasem,但是编译 lasem 需要 glib。如何构建它?

我从https://git.gnome.org/browse/glib/refs/tags 下载 glib-2.37.4。然后我使用 autogen.sh 获取配置文件,运行 make 并安装在 mac 上。我写了一个shell脚本尝试为iOS构建glib,作为打击:

export path=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/:$path
 export CC=arm-apple-darwin10-llvm-gcc-4.2
 export CFLAGS="-arch armv7"
 export LDFLAGS="-miphoneos-version-min=2.0"
 export LD="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld--disable-cxx"
./configure --prefix=/usr/local/ios/ --host=arm-apple-darwin10 --enable-static=yes --enable-shared=no CC=$CC CFLAGS=$CFLAGS CPP=cpp AR=ar LDFLAGS=$LDFLAGS LD=$LD

当我运行这个脚本时,返回:

checking for arm-apple-darwin10-gcc... arm-apple-darwin10-llvm-gcc-4.2
checking whether the C compiler works... no
configure: error: in `/Users/tinyfool/Downloads/glib-2.34.3':
configure: error: C compiler cannot create executables

我能做什么?

【问题讨论】:

  • 别...认真...
  • 顺便说一句,GLib 是在 LGPL 许可下发布的,它与 iOS 存在很多问题,由于静态链接,并且通常在法律上不兼容......
  • GCC - 这个脚本发现它而不是 Clang 作为编译器 - 偶然被弃用为 MacOSX 和 iOS 的编译器 - 至少在 Apple 不再支持或更新版本的情况下他们的开发工具。除非您依靠 MacPorts 或类似工具来获取它,否则它将在下一个版本中消失。
  • 一点也不兼容,只是有点复杂。 LGPL 的“精神”是最终用户应该能够修改 LGPL 源代码并因此改进/更改产品。动态链接时,这与替换动态库一样简单,但使用静态链接时,您需要提供使用的 LGPL 源代码、专有目标文件以及编译和重新链接这些文件的方法,这样仍然可以修改生成的产品.

标签: ios glib


【解决方案1】:

鉴于您已经为 iOS 构建了 libffiproxy-libintl,并将它们安装到与此脚本使用相同的 PREFIX,这将为您构建 GLib:

#! /bin/bash

export MINVER="5.1" # the minimum supported OS version
export SDKVER="5.1" # SDK version
export PREFIX="$HOME/built-for-ios" # where the library goes

export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk"
export PKG_CONFIG_LIBDIR="${PREFIX}/lib/pkgconfig:${SDKROOT}/usr/lib/pkgconfig"
export COMMON_FLAGS="-arch armv7 -isysroot ${SDKROOT}"
export CPPFLAGS="-I${PREFIX}/include ${COMMON_FLAGS} -miphoneos-version-min=${MINVER}"
export CFLAGS="${CPPFLAGS}"
export LDFLAGS="-L${PREFIX}/lib ${COMMON_FLAGS} -Wl,-iphoneos_version_min,${MINVER}"
export CC="${DEVROOT}/usr/bin/gcc"
export CXX="${DEVROOT}/usr/bin/g++"
export OBJC="${CC}"
export LD="${CC}"

[ ! -d "${PREFIX}" ] && mkdir -p "${PREFIX}"
./configure --prefix="${PREFIX}" \
--build="x86_64-apple-darwin" \
--host="arm-apple-darwin" \
--enable-static \
--disable-shared \
glib_cv_stack_grows=no \
glib_cv_uscore=no \
ac_cv_func_posix_getgrgid_r=yes \
ac_cv_func_posix_getpwuid_r=yes

【讨论】:

  • 谢谢。我使用你的脚本成功制作 libffi 和 gettext,在我的 ~/built-for-ios/lib 中有 libintl.a libintl.la 获取文本 libgettextpo.a ...但是当我配置 glib 时仍然说:检查 ngettext in - lintl... no configure: error: *** 您必须在 C 库中支持 gettext,或者使用 *** GNU gettext 库。 (gnu.org/software/gettext/gettext.html
  • 在 config.log 我可以看到“configure:8750: 检查 -lintl 中的 ngettext”,... 架构 armv7 的未定义符号:“_CFArrayGetCount”,引用自:libintl.a 中的 __nl_language_preferences_default( langprefs.o)ld:未找到架构 armv7 collect2 的符号:ld 返回 1 个退出状态
  • 是的,因此引用了 libintl-proxy。改为构建它,它将充当虚拟(代理)实现。
  • 在 glib 的配置阶段,我得到一个意外的configure: error: *** No iconv() implementation found in C library or libiconv,这是否意味着我也需要 x-compile libiconv?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-08
  • 1970-01-01
  • 1970-01-01
  • 2020-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多