There are no mandatory functions that you must implement. You can implement
sth. like a “JNI_OnLoad” if you really want to. Although there is also a
"JNI_OnUnload" (IIRC) it is pretty hard to get that one ever called. I have
not used either yet.
Your “loadLibrary” should never fail, no matter what content your library
has (unless of course you are depending on another library that has not been
loaded yet so that you have unresolved symbols - that’s no different than
other OS’s). You would get failures later if you are instructing the VM to
call a specific “native” (e.g. C/C++) function that cannot be found.
With respect to SDL you should not have to worry a lot about this, because
all the Java --> C and back stuff is handled by SDL already, and all you
need to do is to supply a “libmain.so” with a main() function that contains
your code, and is loaded after SDL itself is loaded.
---------- P?vodn? zpr?va ----------
Od: SparkyNZ
Komu: sdl at lists.libsdl.org
Datum: 27. 5. 2016 3:50:03
P?edm?t: Re: [SDL] Android: SDL Error findLibrary returned null
"
hardcoredaniel wrote:
You need to supply your code in a library (e.g. libmain.so). The C/C++ file
where main(int, char**) is referenced needs to #include “SDL.h”, so that the
main function is replaced with something else.
And in the Java class you need to make sure that “libmain.so” is loaded
after “libSDL2.so”, just add it to the “getLibraries()” function, if not
already done.
OK, I can see the code in the java class that loads library “SDL” and
"main". I wonder… is there a standard that the library needs to adhere to
before it will load correctly? I’m wondering if I’m missing a method or
function that may be required for a library to load successfully. I’m sure
that there are standard DLL entry/init functions with the likes of Windows
but I have no idea when it comes to Android Java trying to load JNI
libraries.
I’ve tried building my app likes this with an almost empty main.cpp:
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c
main.cpp
If my main.cpp only contains an empty main() function, would this cause my
libmain to fail to load because a method/function is missing perhaps??_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"