bugThe FreeType Project - Bugs: bug #35644, Cross-compile FreeType for Android...


You are not allowed to post comments on this tracker with your current authentication level.

bug #35644: Cross-compile FreeType for Android ARM

Submitter:  Sylvain Beucler <Beuc>
Submitted:  Mon 27 Feb 2012 08:56:06 PM UTC
Severity:  3 - Normal Item Group:  Hack required
Status:  Fixed Privacy:  Public
Assigned to:  mpsuzuki Open/Closed:  Closed
Planned Release:  2.4.10

( Jump to the original submission )

Thu 22 Mar 2012 06:03:17 AM UTC, comment #16: 

You should add some ranting :-)

Werner LEMBERG <wl>
Project Administrator
Thu 22 Mar 2012 01:30:11 AM UTC, comment #15: 

Oops, I found this bug had been reported 3 years ago!
Its status is still new :-(

suzuki toshiya <mpsuzuki>
Project Administrator
Wed 21 Mar 2012 06:46:31 AM UTC, comment #14: 

Thanks! Just I updated GIT repository.

Yes, I will report this issue and submit a patch by myself.
It's a pity that Bionic libc has no its own forum to maintain it :-(

suzuki toshiya <mpsuzuki>
Project Administrator
Tue 20 Mar 2012 07:51:28 PM UTC, comment #13: 


The program runs fine on my device!

Apparently there isn't a bug reporting system specific to bionic libc, you need to use the Android one:
- http://source.android.com/source/report-bugs.html
- source.android.com/source/submit-patches.html

Are you willing to report it?

Sylvain Beucler <Beuc>
Tue 20 Mar 2012 12:09:01 PM UTC, comment #12: 

Sorry for your inconvenience caused by my tarball with legacy
config.sub that cannot recognize Android platform. I wish the
built library works well on your device.

I think this issue should be reported to Bionic libc maintainers.
If you know their bugzilla or any other forum to report it,
please let me know. It would be easy to post a patch to fix
this issue, if their direction (C89 mode should be rejected,
or supported) is fixed.

suzuki toshiya <mpsuzuki>
Project Administrator
Tue 20 Mar 2012 11:19:41 AM UTC, comment #11: 


It builds!

But I had to update builds/unix/config.sub :

cd builds/unix; ./configure  '--host=arm-linux-androideabi' '--prefix=/freetype' '--without-zlib'
configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `arm-linux-androideabi': system `androideabi' not recognized
configure: error: /bin/bash ./config.sub arm-linux-androideabi failed

I'm going to test the built library on my device tonight.

Should we file a bug at Android so as to entice them into fixing bionic libc?

Sylvain Beucler <Beuc>
Mon 19 Mar 2012 11:49:07 PM UTC, comment #10: 

Here I upload tarball including testing configure script.

(file #25411)

suzuki toshiya <mpsuzuki>
Project Administrator
Mon 19 Mar 2012 06:28:08 PM UTC, comment #9: 

Simply call the top-level `autogen.sh' script.

Werner LEMBERG <wl>
Project Administrator
Mon 19 Mar 2012 05:32:11 PM UTC, comment #8: 

Hi Suzuki Toshiya (not sure what your first name is - mine is Sylvain, not Beucler, btw),

Can you give me some clues about how to regenerate the autoconf-based files?  autoreconf in builds/unix causes an error from autoheader, and then I got a version mismatch error from libtool.

I'm running Debian Wheezy/testing here.

Sylvain Beucler <Beuc>
Mon 19 Mar 2012 03:45:45 PM UTC, comment #7: 

Attached is a patch to improve configure.ac.
It checks if "-pedantic", "-ansi" works correctly,
and if it works correctly, add them to XX_ANSIFLAGS.
In Android case, "-pedantic" is added, but "-ansi"
is not added. Beucler, could you check please?

(file #25406)

suzuki toshiya <mpsuzuki>
Project Administrator
Mon 19 Mar 2012 02:42:52 PM UTC, comment #6: 

Now I'm writing a patch to improve configure in FreeType2,
but here is more detailed analysis how the error occurs.
platforms/android-9/arch-x86/usr/include/stdint.h has
following conditional definitions for 64bit types:

typedef __int8_t      int8_t;
typedef __uint8_t     uint8_t;
typedef __int16_t     int16_t;
typedef __uint16_t    uint16_t;
typedef __int32_t     int32_t;
typedef __uint32_t    uint32_t;
#if defined(_STDC_INT64_)
typedef __int64_t     int64_t;
typedef __uint64_t    uint64_t;

Although internal types (__int64_t, __uint64_t) seem to be
available always, _STDC_INT64_ is required to use
int64_t, uint64_t.

does not check _STDC_INT64_ (as shown in the first post
of this item) and tries to use int64_t, uint64_t even if
they are unavailable. Thus, error is caused. types.h should
check _STDC_INT64_.

suzuki toshiya <mpsuzuki>
Project Administrator
Mon 19 Mar 2012 02:23:41 AM UTC, comment #5: 

The compile error is because that configure script of FreeType2
adds "-pedantic -ansi" to catch the problems in building.
If I use these options, even hello-world cannot be compiled
as far as including some system header files.
The solution would be:

[FreeType2 side solution] configure should check "-pedantic
-ansi" works or not, even if we use GCC. If it does not work,
dropping "-ansi" and trying "-pedantic" only.

[Android side solution] the integrity/consistency of the libc
headers in the case that uint64_t/int64_t is unavailable by
"-ansi". If android libc maintainer does not want the developers
to build something with "-ansi", some error should be returned.

Anyway, an assumption "-ansi -pedantic" is always available
and working in GCC variants would not be pedantic, it should
be improved :-)

suzuki toshiya <mpsuzuki>
Project Administrator
Mon 19 Mar 2012 01:54:18 AM UTC, comment #4: 

Sorry for quite slow activity about this issue,
today finally I could prepare my environment to cross-build
for Android (I was trying to understand how to use SDK
which is provided without C compiler - the required was
just NDK!). I could reproduce the issue.

suzuki toshiya <mpsuzuki>
Project Administrator
Wed 29 Feb 2012 08:14:34 AM UTC, comment #3: 

Nice, let me know if I can help.

My notes at:
should help you getting started with the Android NDK and its cross-compiler.

Sylvain Beucler <Beuc>
Wed 29 Feb 2012 06:07:55 AM UTC, comment #2: 

Hmm, this issue seems to be related with libc for Android
(bionic libc). To reproduce the issue, learn the standard
process to build something for Android, and consider the
appropriate fix, please give me a few weeks to setup my
machines for the environment.

suzuki toshiya <mpsuzuki>
Project Administrator
Wed 29 Feb 2012 05:45:28 AM UTC, comment #1: 

I take the liberty to assign this problem to Toshiya-san :-)

Werner LEMBERG <wl>
Project Administrator
Mon 27 Feb 2012 08:56:06 PM UTC, original submission:  


I noticed that you need to set CFLAGS="-std=gnu99" to cross-compile FreeType for Android ARM, otherwise there seem to be a confusion with BSD_VISIBLE as described at this page:

The build looks like:

$ make
./builds/unix/libtool --mode=compile arm-linux-androideabi-gcc -pedantic -ansi  -I/usr/src/freetype-2.4.8/objs -I./builds/unix -I/usr/src/freetype-2.4.8/include -c -Wall -g -O2 -DFT_CONFIG_CONFIG_H="<ftconfig.h>" -DFT2_BUILD_LIBRARY -DFT_CONFIG_MODULES_H="<ftmodule.h>"  -o /usr/src/freetype-2.4.8/objs/ftsystem.lo /usr/src/freetype-2.4.8/src/base/ftsystem.c
libtool: compile:  arm-linux-androideabi-gcc -pedantic -ansi -I/usr/src/freetype-2.4.8/objs -I./builds/unix -I/usr/src/freetype-2.4.8/include -c -Wall -g -O2 "-DFT_CONFIG_CONFIG_H=<ftconfig.h>" -DFT2_BUILD_LIBRARY "-DFT_CONFIG_MODULES_H=<ftmodule.h>" /usr/src/freetype-2.4.8/src/base/ftsystem.c  -fPIC -DPIC -o /usr/src/freetype-2.4.8/objs/.libs/ftsystem.o
In file included from /usr/src/ndk-standalone-9/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:64,
                 from /usr/src/freetype-2.4.8/include/freetype/config/ftstdlib.h:101,
                 from ./builds/unix/ftconfig.h:43,
                 from /usr/src/freetype-2.4.8/src/base/ftsystem.c:29:
/usr/src/ndk-standalone-9/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/sys/types.h:137: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_int64_t'
make: *** [/usr/src/freetype-2.4.8/objs/ftsystem.lo] Erreur 1

The last file at line 125:

/* for some applications */
#include <sys/sysmacros.h>

#ifdef __BSD_VISIBLE
typedef        unsigned char        u_char;
typedef        unsigned short        u_short;
typedef        unsigned int        u_int;
typedef        unsigned long        u_long;

typedef uint32_t       u_int32_t;
typedef uint16_t       u_int16_t;
typedef uint8_t        u_int8_t;
typedef uint64_t       u_int64_t;

(I had mentioned this on Planet GNU but obviously you people missed it ;))

Any idea on why the CFLAGS="-std=gnu99" work-around is necessary?

Context info: this page explains in detail how FreeType is compiled for Android and how it's used in the Android build system :


Sylvain Beucler <Beuc>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #25411:  freetype-2.4.9.tar.xz added by mpsuzuki (1MiB - application/octet-stream)
file #25406:  mps20120320a.diff added by mpsuzuki (2KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mpsuzuki (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by Beuc (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.




    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-04-24 wl Open/ClosedOpen Closed
    2012-03-21 mpsuzuki StatusReady For Test Fixed
        Planned ReleaseNone 2.4.10
    2012-03-19 mpsuzuki Attached File- Added freetype-2.4.9.tar.xz, #25411
    2012-03-19 mpsuzuki Attached File- Added mps20120320a.diff, #25406
        StatusConfirmed Ready For Test
    2012-03-19 mpsuzuki StatusNone Confirmed
    2012-02-29 wl Assigned toNone mpsuzuki

    Back to the top

    Powered by Savane 3.9