Talk:Compiling for Android

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Bob the Hamster (talk) 22:01, 1 June 2013 (PDT): I am a bit confused by the freebasic instructions. I understand that I need to create a config.mk and put some stuff in it. I don't know what the toolchain is, except that the android/compile-using-toolchain.sh script seems to populate it, but I have not yet gotten to the step where I try that. Why /tmp ? That seems like a really strange place to put anything.

Bob the Hamster (talk) 22:09, 1 June 2013 (PDT): My config.mk looks like this:

ENABLE_PREFIX=1
prefix=/home/james/misc/fbc-0.90-android
PATH:=/tmp/android-toolchain/bin:$(PATH) 
TARGET_PREFIX=arm-linux-androideabi-

but when I do make compiler it says:

james@rhinoctopus:~/src/misc/fbc-tmc$ make compiler
makefile:414: target `src/rtlib/arm-linux-androideabi-' given more than once in the same rule.
makefile:414: target `obj' given more than once in the same rule.
makefile:414: target `freebasic' given more than once in the same rule.
makefile:445: warning: overriding commands for target `lib/arm-linux-androideabi-'
makefile:417: warning: ignoring old commands for target `lib/arm-linux-androideabi-'
makefile:448: warning: overriding commands for target `lib/arm-linux-androideabi-'
makefile:445: warning: ignoring old commands for target `lib/arm-linux-androideabi-'
makefile:451: warning: overriding commands for target `lib/arm-linux-androideabi-'
makefile:448: warning: ignoring old commands for target `lib/arm-linux-androideabi-'
makefile:459: warning: overriding commands for target `lib/arm-linux-androideabi-'
makefile:451: warning: ignoring old commands for target `lib/arm-linux-androideabi-'
makefile:462: *** multiple target patterns.  Stop.

I assume this is just because I don't know jack about makefiles :)


TMC (talk): That was quite puzzling, but I've discovered that it must be because you have a space at the end of the TARGET_PREFIX line. I sure hate makefiles.

The standalone NDK toolchain is the bare essentials copied from the NDK: tools, headers and libraries to target a single specific arch+android version using a specific GCC/Clang version. I simply put it in /tmp because that's what the NDK docs suggested. Probably because you install multiple of them for your different targets then can delete when done. My own config.mk:

PATH:=/tmp/android-toolchain/bin:$(PATH)
TARGET_PREFIX=arm-linux-androideabi-

ENABLE_PREFIX=1
CFLAGS := -Wfatal-errors -O0 -g
prefix=/home/ralph/local/fbc-0.90-android
V=1

Looking closer at the makefile, I see $prefix is the install location, so you definitely want to specify that, since it's not a normal build of FB; though you could build non-crosscompiling versions of rtlib and fbgfx libraries and install those too and it should work


Bob the Hamster (talk) 12:26, 2 June 2013 (PDT): Yup! You are right. That one extra space was throwing it off.

Bob the Hamster (talk) 13:04, 2 June 2013 (PDT): I was able to get through the whole compiling process, and ended up with an apk, but when I ran it on the device, it crashed with a file-not-found in debuginfo http://pastebin.com/raw.php?i=gxyATZTg

TMC (talk): What is line 352 in common.rbas.bas for you? For me, with no modifications to common.rbas, it is "sizeerror = -1". I don't see which line in debuginfo could throw that error, unless it's possible for a "file not found" error to be printed when attempting to access a file which has already been successfully opened...

You could try using ndk-gdb (instructions on Android Port to see where exactly in libfb the error is thrown from. Also it's a mystery how debuginfo is being called before startup, so the backtrace will be very interesting.

Bob the Hamster (talk) 07:29, 3 June 2013 (PDT): Line 352 in common.rbas.bas is the same for me as for you. Nothing looks unusual in that file. I tried ndk-debug but the SDL logo flickers on the device's screen and the crashes before gdb has a chance to connect to it: http://pastebin.com/raw.php?i=BcEzMxKu


S'orlok Reaves (talk): Just thought I might add that, for Ubuntu users, Free Basic won't compile unless you install lib32ncurses5-dev. I'm not sure why Free Basic complained about this particular library; for everything else, "libWhatever-dev" seemed to work.


S'orlok Reaves (talk): I'm getting "undefined reference to 'SDL_main'" when I try to run ./build.sh inside the sdl-android directory. Is anyone else getting this?

http://pastie.org/8001219


S'orlok Reaves (talk): Ok, I figured it out. The wiki text "Create a symlink from sdl-android/project/jni/application/src to sdl-android/project/jni/application/ohrrpgce" was somewhat inaccurate. You actually want to do something like this:

    cd sdl-android
    ln -s ohrrpgce project/jni/application/src
    
   ...because build.sh expects the link to point locally to "ohrrpgce". If you point it to anything else (subfolder, absolute path, etc.) it will fail.