Sunday, January 15, 2012

linux-android cross-compiling EGL surafce

Here is a simple HelloWorld EGL prog tat creates android window and displays openGL ES Surface
http://jiggawatt.org/badc0de/android/
(main.c)

Here is a Android.mk file for cross compiling this with NDK

LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE:=arm
LOCAL_MODULE:=mini
LOCAL_SRC_FILES:=main.c
LOCAL_MODULE_TAGS:=eng debug
LD_LIBRARY_PATH:=/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/lib
LOCAL_LDLIBS:=\
-L/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/lib \
-lEGL \
-ldl \
-lsurfaceflinger \

-lhardware \
-lhardware_legacy \
-lpixelflinger \

-lwpa_client \
-lemoji \
-lnetutils \
-ljpeg \
-lc \
-llog \
-lexpat \
-lskia \
-lui \
-lcutils \
-lutils \
-lbinder \
-lsurfaceflinger_client \
-lGLESv1_CM

LD:=/home/shivram/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
LOCAL_SHARED_LIBRARIES:=\
EGL \
GLESv1_CM
LOCAL_CFLAGS := \
-DHAVE_CONFIG_H \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include/EGL \
-I/home/shivram/android-ndk-r6b/platforms/android-14/arch-arm/usr/include/GLES \
-DG_THREADS_MANDATORY \
-DG_DISABLE_DEPRECATED \
-Wall \

-Wdeclaration-after-statement \
-Wvla \
-Wpointer-arith \
-Wmissing-declarations \
-Wmissing-prototypes \
-Wredundant-decls \
-Wundef \
-Wwrite-strings \
-Wformat-nonliteral \
-Wformat-security \
-Wold-style-definition \
-Winit-self \
-Wmissing-include-dirs \
-Waddress \
-Waggregate-return \

-Wno-multichar \
-Wnested-externs \
-g \
-nostdlib \
-Bdynamic \
-Wl,-dynamic-linker,/system/bin/linker \
-Wl,--gc-sections \
-Wl,-z,nocopyreloc \
-DGST_DISABLE_DEPRECATED

include $(BUILD_EXECUTABLE)

When we try to compile this.. we get... undefined reference to some pthread functions

To resolve this, the key is to write a wrapper or define those missing functions in ur (main.c) code ;)

No comments: