[Android] Cannot locate symbol when loading custom native so linked with v8

603 views
Skip to first unread message

Henry Ping

unread,
Jun 23, 2017, 2:36:03 PM6/23/17
to v8-users
Hi,

I'm trying to use v8 via NDK in my Android Application.

I built v8 libraries using GN on Ubuntu 14.04 LTS and followed the instructions on https://github.com/v8/v8/wiki/Building-with-GN

I checked out 5.8.283.38 from v8 and did:
1. tools/dev/v8gen.py x64.release
2. ninja -C out.gn/x64.release
3. generate various v8 libraries by running:
ar -rcsD libv8_base.a ../v8_base/*.o
ar -rcsD libv8_libbase.a ../v8_libbase/*.o
ar -rcsD libv8_libsampler.a ../v8_libsampler/*.o
ar -rcsD libv8_libplatform.a ../v8_libplatform/*.o
ar -rcsD libv8_nosnapshot.a ../v8_nosnapshot/*.o
ar -rcsD libv8_snapshot.a ../v8_snapshot/*.o
ar -rcsD libv8_external_snapshot.a ../v8_external_snapshot/*.o

I successfully linked libv8*.a to my native so in my app, however, when launching my App inside emulator, I got the following error:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNSs4_Rep20_S_empty_rep_storageE" referenced by "/data/app/[my native.so]"

Here are settings in my .gclient:
solutions = [
  {
    "managed": False,
    "name": "v8",
    "deps_file": "DEPS",
    "custom_deps": {},
  },
]
target_os = [ 'android' ]

I also did clean rebuilt by adding "v8_static_library=true" to x64.release/args.gn which generates libv8*.a on its own, but I still get the same error.

Any ideas on how to fix this?

btw
I didn't build them but used earlier version of libv8*.a (5.5.372.32), my project builds and launches fine. Unfortunately I couldn't find out how they were built and need to use newer version so that I can use the v8 inspector.

Thanks
Henry  




Henry Ping

unread,
Jun 26, 2017, 2:36:52 PM6/26/17
to v8-users
I also linked the v8 built from 5.8.283.38 with a simple "Hello World" like Android app from https://codelabs.developers.google.com/codelabs/android-studio-cmake/index.html

And still getting the same error related to "_ZNSs4_Rep20_S_empty_rep_storageE" when launching the app in Android Emulator.

Any thoughts/suggestions I can try?

Thanks
Henry

Zac Hansen

unread,
Jun 26, 2017, 4:07:24 PM6/26/17
to v8-users
are you sure you're building and running on the same stdlib?   From what I'm seeing that's a pre-initialized empty string, so it seems pretty fundamental..


--Zac

Henry Ping

unread,
Jun 26, 2017, 5:29:40 PM6/26/17
to v8-users
Thanks, Zac.

Is there way to check stdlib version between build and run time? I assumed they are the same because:
- v8 and the Android app linked with are on the same Ubuntu box
- v8 comes with its own sandboxed dev tools(depot_tools)

I also did objdump on my so linked with new v8, it shows dependency on "_ZNSs4_Rep20_S_empty_rep_storageE" but is not defined:

"

/objdump -T libnative-lib.so | grep Rep20_S_empty

0000000000000000 D *UND* 0000000000000000 _ZNSs4_Rep20_S_empty_rep_storageE
"

Objdump on the same so linked with older version of v8 doesn't show the dependency on "_ZNSs4_Rep20_S_empty_rep_storageE"

Henry
Reply all
Reply to author
Forward
0 new messages