libgdx / gdx-jnigen

jnigen is a small library that can be used with or without libGDX which allows C/C++ code to be written inline with Java source code.
Apache License 2.0
60 stars 25 forks source link

Fix library loading on android #55

Closed Berstanio closed 9 months ago

Berstanio commented 9 months ago

On android we load natives with

System.loadLibrary(platformName);

which expects unprocessed libname:

Loads the native library specified by the libname argument. The libname argument must not contain any platform specific prefix, file extension or path.
obigu commented 9 months ago

Interesting, might this be related? https://github.com/libgdx/libgdx/issues/5863

Berstanio commented 9 months ago

Interesting, might this be related? libgdx/libgdx#5863

No, this fixes a complete breakage of android lib loading introduced in jnigen 2.5.0. 2.5.0 isn't used in libGDX yet

SimonIT commented 9 months ago

Hmm, after having a second look, are you sure it's needed? Because these methods https://github.com/libgdx/gdx-jnigen/blob/21a622def0e981ca0c7aa5410bf3d2f49ef17ec9/gdx-jnigen-loader/src/main/java/com/badlogic/gdx/utils/Os.java#L7-L26 handle the case for android, I think. Or is the lib added by getLibPrefix wrong?

Berstanio commented 9 months ago

Yeah, the lib added is wrong and the suffix is wrong. It will currently result in trying to load something like: liblib<name>..so

SimonIT commented 9 months ago

Ah, I added it probably because the file has added lib to the name, but for loading it's not needed. https://github.com/SimonIT/gdx-jnigen/blob/9d0e3214a1c64cb1f9e1d16a4399c23e5db742b0/gdx-jnigen/src/main/java/com/badlogic/gdx/jnigen/BuildTarget.java#L157-L159