Jackie
Jackie

Reputation: 23519

Android NDK: Linking "error: undefined reference to" GLES functions

So I have the following on my Android.mk....

...
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include /Users/myname/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include
...
LOCAL_LDLIBS := -ldl -lGLESv1_CM -llog

However, when I try running ndk-build I get the following....

/Users/myname/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libSDL.a(SDL_render_gles.o): in function GLES_CreateRenderer:jni/SDL/src/render/opengles/SDL_render_gles.c:189: error: undefined reference to 'glDisableClientState' collect2: ld returned 1 exit status

This of course appears to be an issue linking, however, the compiler worked just fine. I am confused as to why the linking wouldn't work but the compilation would. Anyonw know how I could fix it?

From ndk-build V=1 >Build.log Output

UPDATE:

Ok so I am taking the code found here this compiles fine, however, I am trying to upgrade to PRBoom+ so I dl the code from here and tweak the Android.mk to include the new classes. Once this is done it seems to compile fine, however, it fails to properly link. There are two main errors I see...

First is involving multiple definitions, however, the original (compiled linked fine) code had the same multiple definitions....

/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: ./obj/local/armeabi/objs-debug/prboom_jni/w_mmap.o: multiple definition of 'W_InitCache'

The other type is the OpenGL issues...

/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libSDL.a(SDL_render_gles.o): in function GLES_ResetState:/Users/jackiegleason/Development/Code/prboom4android-base/jni/SDL/src/render/opengles/SDL_render_gles.c:181: error: undefined reference to 'glDisable'

If I copy everything back (using the prboom4android code) everything compiles and links just fine.

Here is a diff of the 2 Android.mk files...

< LOCAL_C_INCLUDES:= $(LOCAL_PATH) $(LOCAL_PATH)/include $(LOCAL_PATH)/../SDL_net/include $(LOCAL_PATH)/../SDL/include $(LOCAL_PATH)/MUSIC $(LOCAL_PATH)/MUSIC/include $(LOCAL_PATH)/TEXTSCREEN $(LOCAL_PATH)/TEXTSCREEN/include
---
> LOCAL_C_INCLUDES:= $(LOCAL_PATH) $(LOCAL_PATH)/include $(LOCAL_PATH)/../SDL_net/include $(LOCAL_PATH)/../SDL/include
28c28
<   f_finale.c p_enemy.c p_spec.c r_plane.c w_mmap.c i_capture.c \
---
>   f_finale.c p_enemy.c p_spec.c r_plane.c w_mmap.c \
31,36c31,33
<   m_bbox.c p_inter.c p_tick.c r_things.c z_zone.c s_advsound.c memio.c \
<   d_client.c i_video.c i_network.c i_system.c PCSOUND/pcsound.c PCSOUND/pcsound_sdl.c SDL/i_sshot.c \
<   i_main.c sc_man.c SDL/i_sound.c jni_doom.c mus2mid.c pcm2wav.c e6y.c SDL/i_joy.c \
<         r_screenmultiply.c hu_tracers.c i_smp.c g_overflow.c i_pcsound.c \
<         MUSIC/dbopl.c MUSIC/flplayer.c MUSIC/portmidiplayer.c MUSIC/midifile.c MUSIC/opl_queue.c MUSIC/vorbisplayer.c MUSIC/dumbplayer.c MUSIC/oplplayer.c MUSIC/madplayer.c MUSIC/opl.c \
<         TEXTSCREEN/txt_button.c TEXTSCREEN/txt_separator.c TEXTSCREEN/txt_gui.c TEXTSCREEN/txt_widget.c TEXTSCREEN/txt_checkbox.c TEXTSCREEN/txt_radiobutton.c TEXTSCREEN/txt_inputbox.c TEXTSCREEN/txt_spinctrl.c TEXTSCREEN/txt_window.c TEXTSCREEN/txt_desktop.c TEXTSCREEN/txt_scrollpane.c TEXTSCREEN/txt_io.c TEXTSCREEN/txt_strut.c TEXTSCREEN/txt_window_action.c TEXTSCREEN/txt_dropdown.c TEXTSCREEN/txt_sdl.c TEXTSCREEN/txt_label.c  TEXTSCREEN/txt_table.c 
---
>   m_bbox.c p_inter.c p_tick.c r_things.c z_zone.c \
>   d_client.c i_video.c i_network.c i_system.c \
>   i_main.c i_sound.c jni_doom.c mmus2mid.c pcm2wav.c

Upvotes: 3

Views: 3969

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57173

Yes, I could download your Build.log.

Your build uses APP_PLATFORM = android-3, which does not have the necessary GL libraries. You can set APP_PLATFORM = android-14 in your Application.mk, or set the target platform for your Android project (Eclipse will update the project.properties file).

You should not add the android-14 includes manually in your Android.mk. When you have correct APP_PLATFORM, the include path will be adjusted accordingly.

Upvotes: 2

Related Questions