Android NDK:链接“错误:未定义引用”GLES函数

时间:2013-05-13 02:16:50

标签: android-ndk

所以我在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

然而,当我尝试运行ndk-build时,我得到以下内容....

  

/Users/myname/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin /../ LIB / GCC /臂-Linux的androideabi / 4.6 /../../../../arm-linux-androideabi/bin/ld:./ obj / local / armeabi / libSDL.a(SDL_render_gles.o):在函数GLES_CreateRenderer中:jni / SDL / src / render / opengles / SDL_render_gles.c:189:错误:对'glDisableClientState'的未定义引用   collect2:ld返回1退出状态

这当然似乎是一个问题,然而,编译器工作正常。我很困惑为什么链接不起作用,但编译会。不知道我怎么解决它?

来自ndk-build V = 1> Build.log Output

更新:

好的所以我正在使用找到的代码here这个编译很好,但是,我正在尝试升级到PRBoom +所以我从here调用代码并调整Android.mk以包含新代码类。一旦完成,它似乎编译好,但是,它无法正确链接。我看到有两个主要错误......

首先涉及多个定义,但是,原始(编译链接精细)代码具有相同的多个定义....

  

/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin /../ LIB / GCC /臂-Linux的androideabi / 4.6 /../../../../arm-linux-androideabi/bin/ld:error:./obj/local/armeabi/objs-debug/prboom_jni/w_mmap.o:'W_InitCache'的多重定义< / p>

另一种类型是OpenGL问题......

  

/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin /../ LIB / GCC /臂-Linux的androideabi / 4.6 /../../../../arm-linux-androideabi/bin/ld:./ obj / local / armeabi / libSDL.a(SDL_render_gles.o):在函数GLES_ResetState中:/ Users / jackiegleason / Development /Code/prboom4android-base/jni/SDL/src/render/opengles/SDL_render_gles.c:181:错误:对'glDisable'的未定义引用

如果我将所有内容复制回来(使用prboom4android代码),所有内容都可以编译和链接。

以下是2个Android.mk文件的差异......

< 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

1 个答案:

答案 0 :(得分:2)

是的,我可以下载你的Build.log

您的构建使用APP_PLATFORM = android-3,它没有必要的GL库。您可以在 Application.mk 中设置APP_PLATFORM = android-14,或者为Android项目设置目标平台(Eclipse将更新 project.properties 文件)。

您不应在 Android.mk 中手动添加android-14包含。如果您有正确的 APP_PLATFORM ,则会相应调整包含路径。