5

I want to use lasem in my iOS App, but compiling lasem needs glib. How to build it?

I download glib-2.37.4 from https://git.gnome.org/browse/glib/refs/tags. I then used autogen.sh to get a configure file, ran make and installed on mac. I wrote a shell script try to build glib for iOS, as blow:

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

When I run this script, return as:

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

What can I do?

tshepang
12.5k25 gold badges98 silver badges140 bronze badges
asked Jul 14, 2013 at 10:33
5
  • Don't... Seriously... Commented Jul 18, 2013 at 23:49
  • 1
    And by the way, GLib is released under the LGPL license, which have a lot of issues with iOS, due to static linking, and is usually incompatible legally... Commented Jul 18, 2013 at 23:51
  • 1
    GCC - which this script is finding instead of Clang as a compiler - is incidentally deprecated as a compiler for both MacOSX and iOS - at least to the extent that Apple is no longer supporting or updating a release with their dev-tools. It will be going away with the next release unless you rely on MacPorts or similar to obtain it. Commented Jul 18, 2013 at 23:57
  • 4
    It is not at all incompatible, it is just a bit complicated. The "spirit" of LGPL is that the end-user should be able to modify the LGPL source-code and improve/change the product as a result. When dynamically linking, this is as easy as replacing the dynamic libraries, but with static linking you need to provide LGPL-source used, proprietary object-files, and a way to compile and relink these, so that modifying the resulting product is still possible. Commented Jul 19, 2013 at 0:01
  • Even with static relinking it is not possible as the user has to upload it to the app store themself breaking copyright and app store laws. LGPL was made for a different world of the past. Commented May 7, 2023 at 13:39

1 Answer 1

8

Given that you have built libffi and proxy-libintl for iOS, and installed both those to the same PREFIX as this script uses, this will build GLib for you:

#! /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
answered Jul 18, 2013 at 20:32
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. I use your script success make libffi and gettext, at my ~/built-for-ios/lib has libintl.a libintl.la get text libgettextpo.a ... But when I configure glib still said that: checking for ngettext in -lintl... no configure: error: *** You must have either have gettext support in your C library, or use the *** GNU gettext library. (gnu.org/software/gettext/gettext.html
At config.log I can see "configure:8750: checking for ngettext in -lintl",... Undefined symbols for architecture armv7: "_CFArrayGetCount", referenced from: __nl_language_preferences_default in libintl.a(langprefs.o) ld: symbol(s) not found for architecture armv7 collect2: ld returned 1 exit status
yes, hence the reference to the libintl-proxy. Build that instead, and it will act as a dummy(proxy)-implementation.
During the configure phase of glib I get an unexpected configure: error: *** No iconv() implementation found in C library or libiconv does it mean I need to x-compile libiconv as well?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.