I just wrote a small c file and its header file. dev_access.c and dev_access.h
I want to link it to the bionic library in android and create a statically/dynamically linked archive file.
My files are in /home/preetam/mydev/ The android sources are in /home/preetam/android_source
The following is my current makefile
CROSS := /home/preetam/bin/CodeSourcery/arm2010/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi
CC := $(CROSS)-gcc
INC_DIR := /home/preetam/android_source/bionic/libc
CFLAGS := -Wall -c -I$(INC_DIR)/include
android_hal: dev_access.o
${CC} ${CFLAGS} dev_access.c -o dev_access.a
clean:
rm -f *.o dev_access.a
I am not sure whats going wrong but header files are not linking and some missing and redefinition errors are coming up. The following is the Console output:
/home/preetam/bin/CodeSourcery/arm2010/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc -c -Wall -I/home/preetam/android_source/bionic/libc/include -static -c -o dev_access.o dev_access.c
In file included from /home/preetam/android_source/bionic/libc/include/stdio.h:42,
from dev_access.c:1:
/home/preetam/android_source/bionic/libc/include/sys/_types.h:40: fatal error: machine/_types.h: No such file or directory
compilation terminated.
make: *** [dev_access.o] Error 1
First of all, Is my Makefile correct? Whats the proper way to link your programs with bionic libc ? How to make the final object an archive?
You should be using these include paths for bionic:
libc/arch-$ARCH/include
libc/include
libc/kernel/common
libc/kernel/arch-$ARCH
ar might have some switches for it...
EDIT: The switch is cr
ar -crv <libname> <source_object>