bgfx: could not load library "libc++_shared.so"

java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "libc++_shared.so" needed by "libexample-00-helloworldRelease.so"; caused by library "libc++_shared.so" not found

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@hellojql that’s how android works, if your shared library needs any other shared library, you need to load it from Java, so just create proxy activity like this:

package %pkg_name%;
import android.os.Bundle;

public class %activity_name% extends android.app.NativeActivity
{
	static
	{
		System.loadLibrary("libc++_shared.so");
	}
}

and refer your %pkg_name%.%activity_name% in <activity android:name= field in android manifest instead of NativeActivity there. android.app.lib_name still needs to point to app’s so file.

For me I made it work by coping C:\Users\%username%\AppData\Local\Android\sdk\ndk-bundle\sources\cxx-stl\llvm-libc++\libs\%platform%\libc++_shared.so together in .apk

Also check in bx/scripts/toolchain.lua there are this lines:

	if _OPTIONS["with-android"] then
		androidPlatform = "android-" .. _OPTIONS["with-android"]
	end

By default it only builds for android-24 (which is 7.0+) and might be a bit new to your device.

I’m not sure why we need shared c++ lib in a first place though.

@hellojql yeah it should, my current one on Windows:

set ANDROID_SDK_ROOT=C:/Users/%USERNAME%/AppData/Local/Android/sdk
set ANDROID_NDK_ROOT=%ANDROID_SDK_ROOT%/ndk-bundle
set ANDROID_NDK_ARM=%ANDROID_NDK_ROOT%/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
set ANDROID_NDK_MIPS=%ANDROID_NDK_ROOT%/toolchains/mipsel-linux-android-4.9/prebuilt/windows-x86_64
set ANDROID_NDK_X86=%ANDROID_NDK_ROOT%/toolchains/x86-4.9/prebuilt/windows-x86_64
set ANDROID_NDK_CLANG=%ANDROID_NDK_ROOT%/toolchains/llvm/prebuilt/windows-x86_64

thank you @jimon

@jimon Thanks for replying here! 👍

@hellojql yes, as I said, if you compile with android-24 and run on anything below 7.0 you will get __aeabi_memclr4 not found error. So: lookup your android version on a phone/tablet, convert it to API level here https://source.android.com/source/build-numbers and place correct value in bx/scripts/toolchain.lua, after that it should work.

PS. one line got dropped, there are this lines in toolchain file:

	local androidPlatform = "android-24"
	if _OPTIONS["with-android"] then
		androidPlatform = "android-" .. _OPTIONS["with-android"]
	end

just replace android-24 with whatever android-XX is corresponding to your device OS version, or use with-android option to pass this value externally