Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix library loading on android #55

Merged
merged 1 commit into from Dec 18, 2023

Conversation

Berstanio
Copy link
Contributor

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.

Copy link
Member

@SimonIT SimonIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks

@obigu
Copy link

obigu commented Dec 18, 2023

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

@Berstanio
Copy link
Contributor Author

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
Copy link
Member

SimonIT commented Dec 18, 2023

Hmm, after having a second look, are you sure it's needed? Because these methods

public String getJniPlatform () {
if (this == Os.Windows) return "win32";
if (this == Os.Linux) return "linux";
if (this == Os.MacOsX) return "mac";
return "";
}
public String getLibPrefix () {
if (this == Os.Linux || this == Os.Android || this == Os.MacOsX) {
return "lib";
}
return "";
}
public String getLibExtension () {
if (this == Os.Windows) return "dll";
if (this == Os.Linux) return "so";
if (this == Os.MacOsX) return "dylib";
return "";
}

handle the case for android, I think. Or is the lib added by getLibPrefix wrong?

@Berstanio
Copy link
Contributor Author

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
Copy link
Member

SimonIT commented Dec 18, 2023

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

@PokeMMO PokeMMO merged commit 4c011de into libgdx:master Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants