SLD2.0 on Android - Undefined reference to SDL_main

The android-project is just a skeleton. You still need to add your own code that uses libSDL, to make it do anything.

So typically you’ll need to add your own application code in jni/src/. Somewhere in there you’ll have a function SDL_main(), which is your application’s entry point. (The equivalent of main() in a normal C program.)

**
The android-project is just a skeleton. You still need to add your own
code that uses libSDL, to make it do anything.

So typically you’ll need to add your own application code in jni/src/.
Somewhere in there you’ll have a function SDL_main(), which is your
application’s entry point. (The equivalent of main() in a normal C program.)

BTW what is the “best” way to do a real app? To change my ID from
org.libsdl.app to org.ggsoft.etw I’ve had to write these wrappers:

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeResize( JNIEnv*
env, jclass jcls, jint width, jint height, jint format) {
Java_org_libsdl_app_SDLActivity_onNativeResize(env, jcls, width,
height, format);
}

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeKeyDown(JNIEnv*
env, jclass jcls, jint keycode) {
Java_org_libsdl_app_SDLActivity_onNativeKeyDown(env, jcls, keycode);
}

[…]

There is a way to avoid avoid this? :)On Tue, Feb 19, 2013 at 9:50 AM, pmacfarlane wrote:


Bye,
Gabry

No. I think everyone just does the same, or more likely adapts the
existing template file where someone has already done it and blogged
about it.

http://mdqinc.com/blog/2011/11/using-your-own-app-name-in-a-sdl-android-app/

Cheers,
Richard.On Wed, Feb 20, 2013 at 10:25 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

BTW what is the “best” way to do a real app? To change my ID from
org.libsdl.app to org.ggsoft.etw I’ve had to write these wrappers:

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeResize( JNIEnv* env,
jclass jcls, jint width, jint height, jint format) {
Java_org_libsdl_app_SDLActivity_onNativeResize(env, jcls, width, height,
format);
}

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeKeyDown(JNIEnv* env,
jclass jcls, jint keycode) {
Java_org_libsdl_app_SDLActivity_onNativeKeyDown(env, jcls, keycode);
}

[…]

There is a way to avoid avoid this? :slight_smile:

Did you follow the guide in README.android? Does that not solve the issues
with identifying the app?

Jonny DOn Wed, Feb 20, 2013 at 5:48 PM, Richard Tew <richard.m.tew at gmail.com>wrote:

On Wed, Feb 20, 2013 at 10:25 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

BTW what is the “best” way to do a real app? To change my ID from
org.libsdl.app to org.ggsoft.etw I’ve had to write these wrappers:

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeResize( JNIEnv*
env,
jclass jcls, jint width, jint height, jint format) {
Java_org_libsdl_app_SDLActivity_onNativeResize(env, jcls, width,
height,
format);
}

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeKeyDown(JNIEnv*
env,
jclass jcls, jint keycode) {
Java_org_libsdl_app_SDLActivity_onNativeKeyDown(env, jcls, keycode);
}

[…]

There is a way to avoid avoid this? :slight_smile:

No. I think everyone just does the same, or more likely adapts the
existing template file where someone has already done it and blogged
about it.

http://mdqinc.com/blog/2011/11/using-your-own-app-name-in-a-sdl-android-app/

Cheers,
Richard.


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

2013/2/20 Richard Tew <richard.m.tew at gmail.com>> On Wed, Feb 20, 2013 at 10:25 PM, Gabriele Greco <gabriele.greco at darts.it> wrote:

BTW what is the “best” way to do a real app? To change my ID from
org.libsdl.app to org.ggsoft.etw I’ve had to write these wrappers:

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeResize( JNIEnv*
env,
jclass jcls, jint width, jint height, jint format) {
Java_org_libsdl_app_SDLActivity_onNativeResize(env, jcls, width,
height,
format);
}

extern “C” void Java_org_ggsoft_etw_SDLActivity_onNativeKeyDown(JNIEnv*
env,
jclass jcls, jint keycode) {
Java_org_libsdl_app_SDLActivity_onNativeKeyDown(env, jcls, keycode);
}

[…]

There is a way to avoid avoid this? :slight_smile:

No. I think everyone just does the same, or more likely adapts the
existing template file where someone has already done it and blogged
about it.

http://mdqinc.com/blog/2011/11/using-your-own-app-name-in-a-sdl-android-app/

I need to add an update to that blog post, in the time since I wrote it, I
found that copying SDLActivity.java from SDL into your own project,
modifying it so it loads the additional libraries you need in the "static"
segment (which is something you can’t override in practice, as far as I
tested), and then inherit your own Activity from org.libsdl.app.SDLActivity
is easier than writing the glue code as I explained there. The glue code
alternative should still be useful if your Activity departs greatly from
the default behaviours found in SDLActivity, such as in the case of a live
wallpaper, but for a regular game or app, inheriting from SDL’s SDLActivity
is the recommended method, at least in my opinion.


Gabriel.

Gabriel,

This is the approach I took. (My own class inheriting from SDLActivity.)

I tried to make as few changes as possible to SDLActivity. I found I could have my own static{} section in my own class to load the libraries I need, and just load SDL2 from SDLActivity. This tip could be put in the README, and remove the commented out example library loads from SDLActivity.

The only other changes were to make the volume keys work, and changed to a RelativeLayout to make AdMob integration easier.

I still have to merge in changes when I update from hg, but they are minimal.

Regards,
Philip.

2013/2/21 pmacfarlane

**
Gabriel,

This is the approach I took. (My own class inheriting from SDLActivity.)

I tried to make as few changes as possible to SDLActivity. I found I could
have my own static{} section in my own class to load the libraries I need,
and just load SDL2 from SDLActivity. This tip could be put in the README,
and remove the commented out example library loads from SDLActivity.

The only other changes were to make the volume keys work, and changed to a
RelativeLayout to make AdMob integration easier.

I still have to merge in changes when I update from hg, but they are
minimal.

Regards,
Philip.

The problem I had with adding my own static section was that I found out
that the base class static version was being run first, and given inter
dependencies I had, I couldn’t load the rest of the libraries I needed in a
separate static block. So, I modify SDLActivity’s static block, it’s a
small change and Mercurial merges it with no problem when changes are
applied to SDLActivity.java–
Gabriel.