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,111
  • 21
  • 91
  • 136
Tinyfool
  • 1,460
  • 2
  • 18
  • 40
  • Don't... Seriously... – Macmade Jul 18 '13 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... – Macmade Jul 18 '13 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. – marko Jul 18 '13 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. – Havard Graff Jul 19 '13 at 00: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. – Lothar May 07 '23 at 13:39

1 Answers1

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
Havard Graff
  • 2,805
  • 1
  • 15
  • 16
  • 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. (http://www.gnu.org/software/gettext/gettext.html – Tinyfool Jul 19 '13 at 09:06
  • 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 – Tinyfool Jul 19 '13 at 09:09
  • yes, hence the reference to the libintl-proxy. Build that instead, and it will act as a dummy(proxy)-implementation. – Havard Graff Jul 19 '13 at 11:48
  • 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? – duhanebel Jul 29 '14 at 10:42