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?
-
Don't... Seriously...Macmade– Macmade2013年07月18日 23:49:45 +00:00Commented Jul 18, 2013 at 23:49
-
1And 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– Macmade2013年07月18日 23:51:38 +00:00Commented Jul 18, 2013 at 23:51
-
1GCC - 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– marko2013年07月18日 23:57:57 +00:00Commented Jul 18, 2013 at 23:57
-
4It 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– Havard Graff2013年07月19日 00:01:18 +00:00Commented 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.Lothar– Lothar2023年05月07日 13:39:07 +00:00Commented May 7, 2023 at 13:39
1 Answer 1
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
Havard Graff
2,8401 gold badge18 silver badges16 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Tinyfool
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
Tinyfool
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
Havard Graff
yes, hence the reference to the libintl-proxy. Build that instead, and it will act as a dummy(proxy)-implementation.
duhanebel
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?default