SDL 2.0 for android, in Ubuntu: issues with r9 ndk-build

Hi,

I’m trying to setup the android version of SDL 2.0 in Ubuntu linux with the r9 NDK.

I followed the instructions in README-android.txt and tutorials in the wiki exactly.

Copy the android-project from the SDL source into my project directory.
Then copy the SDL source into the project directories jni directory.
Added my source file (at this point a cpp file with an empty main function). to /jni/src/Android.mk.

First problem when running ndk-build was:

“android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found”

This was solvable by renaming the linux-x86_64 folder in the NDK to linux-x86.

Now, I’m stuck on this when executing ndk-build:

/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: 1: /home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Syntax error: “(” unexpected
make: *** [obj/local/armeabi/objs/SDL2/src/SDL_assert.o] Error 2

When executing as ndk-build V=1:

rm -f ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/mips/lib*.so ./libs/x86/lib*.so
rm -f ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/mips/gdbserver ./libs/x86/gdbserver
rm -f ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/mips/gdb.setup ./libs/x86/gdb.setup
Compile thumb : SDL2 <= SDL_assert.c
/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs/SDL2/src/SDL_assert.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/SDL/include -Ijni/SDL -DANDROID -DGL_GLEXT_PROTOTYPES -Wa,–noexecstack -Wformat -Werror=format-security -I/home/benista/Downloads/android-ndk-r9/platforms/android-9/arch-arm/usr/include -c jni/SDL/src/SDL_assert.c -o ./obj/local/armeabi/objs/SDL2/src/SDL_assert.o
/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: 1: /home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Syntax error: “(” unexpected
make: *** [obj/local/armeabi/objs/SDL2/src/SDL_assert.o] Error 2

Thoughts on how to fix this?

Which version of ubuntu? Ubuntu is (or at least was) using the dash, not
the bash - maybe that is the problem. You can also give my small
android-sdl2-example project a try [1]. It was done with a ubuntu system.

[1] http://mgerhardy.blogspot.de/Am 16.10.2013 09:48, schrieb gharen:

Hi,

I’m trying to setup the android version of SDL 2.0 in Ubuntu linux with the r9 NDK.

I followed the instructions in README-android.txt and tutorials in the wiki exactly.

Copy the android-project from the SDL source into my project directory.
Then copy the SDL source into the project directories jni directory.
Added my source file (at this point a cpp file with an empty main function). to /jni/src/Android.mk.

First problem when running ndk-build was:

“android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found”

This was solvable by renaming the linux-x86_64 folder in the NDK to linux-x86.

Now, I’m stuck on this when executing ndk-build:

/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: 1: /home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Syntax error: “(” unexpected
make: *** [obj/local/armeabi/objs/SDL2/src/SDL_assert.o] Error 2

When executing as ndk-build V=1:

rm -f ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/mips/lib*.so ./libs/x86/lib*.so
rm -f ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/mips/gdbserver ./libs/x86/gdbserver
rm -f ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/mips/gdb.setup ./libs/x86/gdb.setup
Compile thumb : SDL2 <= SDL_assert.c
/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs/SDL2/src/SDL_assert.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/SDL/include -Ijni/SDL -DANDROID -DGL_GLEXT_PROTOTYPES -Wa,–noexecstack -Wformat -Werror=format-security -I/home/benista/Downloads/android-ndk-r9/platforms/android-9/arch-arm/usr/include -c jni/SDL/src/SDL_assert.c -o ./obj/local/armeabi/objs/SDL2/src/SDL_assert.o
/home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: 1: /home/benista/Downloads/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Syntax error: “(” unexpected
make: *** [obj/local/armeabi/objs/SDL2/src/SDL_assert.o] Error 2

Thoughts on how to fix this?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

gharen wrote:

This was solvable by renaming the linux-x86_64 folder in the NDK to linux-x86.

definitely don’t do this. you didn’t say, but the usual way to run ndk-build is using the environment variable $NDK like this:

Code:
$NDK/ndk-build

if this gives you an error then your environment variable is set up incorrectly. this may indicate other problems with the way the ndk was installed / set up.

i’m not an expert on the ndk but if you renamed the folder containing 64bit code so it has the name for the folder that should contain 32bit code, it could cause problems. also if your $NDK environment variable is pointing to the 32bit code that could cause other problems.

i got an android project to compile on ubuntu and posted detailed steps here on the forum not long ago.

HTH