7

我正在尝试在 Ubuntu 上为 Android 编译 SDL2。

我用 ./configure --host=arm-linux-androideabi 配置 SDL2

使用 ndk-build 编译后,我得到一系列未定义的引用:

Compile thumb  : SDL2-2.0.0 <= SDL_androidkeyboard.c
Compile thumb  : SDL2-2.0.0 <= SDL_androidtouch.c
Compile thumb  : SDL2-2.0.0 <= SDL_androidvideo.c
Compile thumb  : SDL2-2.0.0 <= SDL_androidwindow.c
SharedLibrary  : libSDL2-2.0.0.so
/home/ire018/Applications/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/ire018/workspace/SDLActivity/obj/local/armeabi/objs/SDL2-2.0.0/src/audio/SDL_audio.o: in function bootstrap:SDL_audio.c(.data.rel.ro+0x0): error: undefined reference to 'PULSEAUDIO_bootstrap'
/home/ire018/Applications/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/ire018/workspace/SDLActivity/obj/local/armeabi/objs/SDL2-2.0.0/src/audio/SDL_audio.o: in function bootstrap:SDL_audio.c(.data.rel.ro+0x4): error: undefined reference to 'DISKAUD_bootstrap'
/home/ire018/Applications/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/ire018/workspace/SDLActivity/obj/local/armeabi/objs/SDL2-2.0.0/src/core/android/SDL_android.o: in function Java_org_libsdl_app_SDLActivity_onNativeResize:/home/ire018/workspace/SDLActivity/jni/SDL2-2.0.0/src/core/android/SDL_android.c:148: error: undefined reference to 'Android_SetScreenResolution'
/home/ire018/Applications/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/ire018/workspace/SDLActivity/obj/local/armeabi/objs/SDL2-2.0.0/src/core/android/SDL_android.o: in function Java_org_libsdl_app_SDLActivity_onNativeKeyDown:/home/ire018/workspace/SDLActivity/jni/SDL2-2.0.0/src/core/android/SDL_android.c:155: error: undefined reference to 'Android_OnKeyDown'
/home/ire018/Applications/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/ire018/workspace/SDLActivity/obj/local/armeabi/objs/SDL2-2.0.0/src/core/android/SDL_android.o: in function Java_org_libsdl_app_SDLActivity_onNativeKeyUp:/home/ire018/workspace/SDLActivity/jni/SDL2-2.0.0/src/core/android/SDL_android.c:162: error: undefined reference to 'Android_OnKeyUp'

有什么建议么?

4

2 回答 2

4

如果您使用的是 ndk-build 系统,则不必使用“配置”。

虽然技术上可行,但使用“configure;make”(即自动工具方式)将 SDL2 交叉编译到 Android 可能存在错误。人们所做的只是使用提供的 Android.mk 文件并使用 ndk-build 直接构建(请参阅“构建应用程序”标题下的 Readme-android.txt 中提供的说明)

于 2013-09-20T13:27:02.793 回答
2

从一个新压缩的 SDL 存档中,我建议简单地使用该ndk-build命令来构建适用于 Android 的 SDL。这是我使用的命令

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk \
    APP_PLATFORM=android-18

您必须调整APP_PLATFORM配置的值并确保使用提供 GLES 2 的 Android API。

于 2013-09-26T14:18:42.970 回答