为Android编译SDL2

问题描述 投票:7回答:3

我正在尝试在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'

有什么建议吗?

android compilation linker sdl sdl-2
3个回答
4
投票

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

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


2
投票

[从刚解压缩的SDL存档中,我建议仅使用ndk-build命令来构建Android的SDL。这是the command I use

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

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


0
投票

https://github.com/AlexanderAgd/SDL2-Android

Bash脚本下载并构建:SDL2SDL2_imageSD2_mixerSDL2_netSDL2_ttfSDL2_gfx

对于Android设备。仅要求NDK,不要求Grandle或Java,仅要求C / C ++。

© www.soinside.com 2019 - 2024. All rights reserved.