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

dlopen failed: library "mgba_libretro_android.so" not found #14

Open
JustMeDaFaq opened this issue Aug 22, 2020 · 8 comments
Open

dlopen failed: library "mgba_libretro_android.so" not found #14

JustMeDaFaq opened this issue Aug 22, 2020 · 8 comments
Labels
question Further information is requested

Comments

@JustMeDaFaq
Copy link

Hi,
i just load up the project in Android Studio.
Make sure to change the hardcoded paths to existing ones in SampleActivity..

When
retroView = GLRetroView(this, "mgba_libretro_android.so", pathtogame, "", "", LibretroDroid.SHADER_LCD)
gets called tho, the above error gets thrown.

Does happen with any other core too.
It happens on:

void LibretroDroid::Core::open(const std::string& soCorePath) {
    libHandle = dlopen(soCorePath.c_str(), RTLD_LOCAL);

To get the detailed (in headline) error log i logged dlerror() like

void LibretroDroid::Core::open(const std::string& soCorePath) {
    libHandle = dlopen(soCorePath.c_str(), RTLD_LOCAL);
    if (!libHandle) {
        LOGE("Cannot dlopen library, closing");
        LOGE("%s",dlerror());

Any idea? :)

@JustMeDaFaq JustMeDaFaq changed the title dlopen failed: mgba_libretro_android.so not found dlopen failed: library "mgba_libretro_android.so" not found Aug 22, 2020
@Swordfish90 Swordfish90 added the question Further information is requested label Aug 22, 2020
@Swordfish90
Copy link
Owner

Hi,

Yeah, the current sample application is just terrible. You need to provide the mgba core in the respective jniLib forlder for your architecture.

Just check how this is done for arm64. You can get the proper so file from buildbot.

@JustMeDaFaq
Copy link
Author

Hi, thats what i already did, and why its so confusing to me :(
https://s12.directupload.net/images/200822/fpkpjxsi.png

@JustMeDaFaq
Copy link
Author

JustMeDaFaq commented Aug 23, 2020

EDIT: Seems to be related to the android version, testing with android 7, it doesnt work Can be reproduced by creating a x86 or x86_64 device on android nougat using the strandard avd manager :)
It does work on android 8, just 7 seems to be not working

@Swordfish90
Copy link
Owner

Mmmmh. This seems very strange. Could you please try renaming the library to "libmgba_libretro_android.so"? Maybe the library doesn't get extracted to the lib directory because the filename doesn't start with "lib".

@JustMeDaFaq
Copy link
Author

JustMeDaFaq commented Aug 25, 2020

Librarys got extracted correctly. It seems tho that android 7 and previous dont like to only get the librarys name.
So to work, when passing the .so on creation of the GLRetroView, you can just append the path to the apps native lib dir, in kotlin thats then like:
retroView = GLRetroView(this, getApplicationInfo().nativeLibraryDir+"/mgba_libretro_android.so", "/storage/emulated/0/test.gba", filesDir.absolutePath, cacheDir.absolutePath, LibretroDroid.SHADER_CRT)

Works fawlessly now, thanks! :)

@tytydraco
Copy link
Contributor

Thanks for the solution, I'll be using this workaround until the LibretroDroid library is updated (unless it's a wontfix).

@tytydraco
Copy link
Contributor

BIG heads up:

With release APKs, the libretro library MUST BEGIN WITH lib. For example, "mgba_libretro_android.so" will NOT be extracted upon launch in a release APK. However, "libmgba_libretro_android.so" WILL.

@Swordfish90
Copy link
Owner

Swordfish90 commented Oct 27, 2020

@tytydraco Yeah, there are lots of traps in there. The library has to start with "lib" to be copied into the native library directory.

The path is passed automatically to dlopen so you can also specify the library name ("foo" is actually resolved into "libfoo.so").

But here's the kicker: the default Android behaviour changed with gradle plugin 3.6.0. Libraries are no longer installed in the native library directory, but you need to specify a flag in gradle.properties AND put extractNativeLibs=true in Manifest.

I'm planning to write a blog post in the future since I've lost many days on the topic. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants