Help me build glib2.0 library (I'm use glib-2.36.3) for ARM !

Dich Kieu
Hi everybody !

I build glib2.0 for FriendlyARM but get erorr :

make[4]: Entering directory `/home/kdich/Downloads/glib-2.36.3/gobject'
CC libgobject_2_0_la-gatomicarray.lo
CC libgobject_2_0_la-gbinding.lo
CC libgobject_2_0_la-gboxed.lo
CC libgobject_2_0_la-gclosure.lo
gclosure.c:29:17: error: ffi.h: No such file or directory
gclosure.c:1128: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
gclosure.c: In function 'value_from_ffi_type':
gclosure.c:1217: error: 'ffi_arg' undeclared (first use in this function)
gclosure.c:1217: error: (Each undeclared identifier is reported only once
gclosure.c:1217: error: for each function it appears in.)
gclosure.c:1217: error: 'int_val' undeclared (first use in this function)
gclosure.c:1217: error: expected expression before ')' token
gclosure.c: At top level:
gclosure.c:1296: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
gclosure.c: In function 'g_cclosure_marshal_generic':
gclosure.c:1391: error: 'ffi_type' undeclared (first use in this function)
gclosure.c:1391: error: 'rtype' undeclared (first use in this function)
gclosure.c:1392: error: ISO C90 forbids mixed declarations and code
gclosure.c:1394: error: 'atypes' undeclared (first use in this function)
gclosure.c:1395: error: ISO C90 forbids mixed declarations and code
gclosure.c:1397: error: 'ffi_cif' undeclared (first use in this function)
gclosure.c:1397: error: expected ';' before 'cif'
gclosure.c:1398: error: ISO C90 forbids mixed declarations and code
gclosure.c:1405: error: implicit declaration of function
'value_to_ffi_type'
gclosure.c:1409: error: 'ffi_type_void' undeclared (first use in this
function)
gclosure.c:1412: error: 'ffi_arg' undeclared (first use in this function)
gclosure.c:1415: error: expected expression before ')' token
gclosure.c:1427: error: 'ffi_type_pointer' undeclared (first use in this
function)
gclosure.c:1451: error: implicit declaration of function 'ffi_prep_cif'
gclosure.c:1451: error: 'cif' undeclared (first use in this function)
gclosure.c:1451: error: 'FFI_DEFAULT_ABI' undeclared (first use in this
function)
gclosure.c:1451: error: 'FFI_OK' undeclared (first use in this function)
gclosure.c:1454: error: implicit declaration of function 'ffi_call'
gclosure.c: In function 'g_cclosure_marshal_generic_va':
gclosure.c:1469: error: 'ffi_type' undeclared (first use in this function)
gclosure.c:1469: error: 'rtype' undeclared (first use in this function)
gclosure.c:1470: error: ISO C90 forbids mixed declarations and code
gclosure.c:1472: error: 'atypes' undeclared (first use in this function)
gclosure.c:1473: error: ISO C90 forbids mixed declarations and code
gclosure.c:1476: error: 'ffi_cif' undeclared (first use in this function)
gclosure.c:1476: error: expected ';' before 'cif'
gclosure.c:1477: error: ISO C90 forbids mixed declarations and code
gclosure.c:1489: error: 'ffi_type_void' undeclared (first use in this
function)
gclosure.c:1492: error: 'ffi_arg' undeclared (first use in this function)
gclosure.c:1495: error: expected expression before ')' token
gclosure.c:1504: error: 'ffi_type_pointer' undeclared (first use in this
function)
gclosure.c:1525: error: implicit declaration of function 'va_to_ffi_type'
gclosure.c:1547: error: 'cif' undeclared (first use in this function)
gclosure.c:1547: error: 'FFI_DEFAULT_ABI' undeclared (first use in this
function)
gclosure.c:1547: error: 'FFI_OK' undeclared (first use in this function)
make[4]: *** [libgobject_2_0_la-gclosure.lo] Error 1
make[4]: Leaving directory `/home/kdich/Downloads/glib-2.36.3/gobject'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/kdich/Downloads/glib-2.36.3/gobject'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/kdich/Downloads/glib-2.36.3/gobject'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/kdich/Downloads/glib-2.36.3'
make: *** [all] Error 2

My setup for variable enviroment :
xport
PREFIX=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root
export CFLAGS="-O2 -I$PREFIX/include -I$PREFIX/usr/include"
export CPPFLAGS="-I$PREFIX/include -I$PREFIX/usr/include"
export LDFLAGS="-L$PREFIX/lib -L$PREFIX/usr/lib"

export CC=arm-linux-gcc
export CXX=arm-linux-g++
export LD=arm-linux-ld
export NM="arm-linux-nm -B"
export RANLIB=arm-linux-ranlib
export STRIP=arm-linux-strip
export OBJCOPY=arm-linux-objcopy


export LDFLAGS=-L$PREFIX/lib
export CFLAGS="-g -I$PREFIX/include"
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH

Everyone help me, please !

Thanks very much !

Juergen Beisert
You should fix this error message:
  "gclosure.c:29:17: error: ffi.h: No such file or directory"

Dich Kieu
Thanks for reply !

Yes, I know, but I'dont know how fix. Everybody help me ??

davef
You just got to find a file called ffi.h and include it in the source
somewhere.  Have you got a ffi.c in there already?

Nitish Gugale
Hey I had the same error recently.
 it is because glib need libffi. so make sure you have added 
 libffi/include path in your include flags.

Dich Kieu
Thanks Nitish Gugale !

I think so, too. It's work fine !

Dich Kieu
Thanks all !

Hafiz Muhammad Shafiq
I am also facing this problem. 

Please guide me how to add libffi/include path in include flags

karan chandra
Hi All,

Here with I am sharing my log, When I am cross compiling glib using Arm
tool chain arm-none-linux-gnueabi.Please provide any suggestions to resolve
this issue.

reg,
karn


make[4]: Entering directory '/home/shekar/Downloads/glib-2.42.2/gobject'
  CC       libgobject_2_0_la-gclosure.lo
gclosure.c:27: fatal error: ffi.h: No such file or directory
compilation terminated.
Makefile:1430: recipe for target 'libgobject_2_0_la-gclosure.lo' failed
make[4]: *** [libgobject_2_0_la-gclosure.lo] Error 1
make[4]: Leaving directory '/home/shekar/Downloads/glib-2.42.2/gobject'
Makefile:1634: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/shekar/Downloads/glib-2.42.2/gobject'
Makefile:993: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/shekar/Downloads/glib-2.42.2/gobject'
Makefile:1215: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/shekar/Downloads/glib-2.42.2'
Makefile:857: recipe for target 'all' failed
make: *** [all] Error 2

davef
http://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_2...

Similarly, additional directories can be added to the link path using the
environment variable LIBRARY_PATH. For example, the following commands will
add '/opt/gdbm-1.8.3/lib' to the link path:

$ LIBRARY_PATH=/opt/gdbm-1.8.3/lib
$ export LIBRARY_PATH

Just a suggestion.  I guess you put libffi source files in a named
directory and then change LIBRARY_PATH accordingly.

davef
PS: note the comment about .bashrc at the top of that page.

Or those lines are placed in .profile depending on your host distribution.

Or you can type those commands in your current terminal session before
running make.