v8 Android link error()

230 views
Skip to first unread message

Coulson Chen

unread,
Apr 13, 2018, 6:37:57 AM4/13/18
to v8-users
I build v8 static libraries for android successfully(using V8 6.5), and then embed it in andoid app(using the hello-world.cc demo from official wiki. Android studio 3.1,Cmake),but error  like the follow takes place while building the APK
Build command failed.
Error while executing process /usr/local/v8/v8/third_party/android_tools/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /mnt/share/V8Wrapper/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target native-lib}
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so
FAILED: : && /usr/local/v8/v8/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=armv7-none-linux-androideabi --gcc-toolchain=/usr/local/v8/v8/third_party/android_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/usr/local/v8/v8/third_party/android_ndk/sysroot -fPIC -isystem /usr/local/v8/v8/third_party/android_ndk/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /usr/local/v8/v8/third_party/android_ndk/platforms/android-16/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -L/usr/local/v8/v8/third_party/android_ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o  /usr/local/v8/v8/third_party/android_ndk/platforms/android-16/arch-arm/usr/lib/liblog.so -landroid ../../../../src/main/cpp/armeabi-v7a/libv8_base.a ../../../../src/main/cpp/armeabi-v7a/libv8_nosnapshot.a -latomic -lm "/usr/local/v8/v8/third_party/android_ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++.a" && :
../../src/isolate.cc:0: error: undefined reference to 'vtable for v8::internal::SetupIsolateDelegate'
/usr/local/v8/v8/third_party/android_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

the key point is " 'vtable for v8::internal::SetupIsolateDelegate'",is the libv8_base.a  not correct? 

Any help is appreciated!

Manuel Rivera

unread,
Apr 29, 2018, 5:38:02 PM4/29/18
to v8-users
I

young louis

unread,
Aug 14, 2018, 3:02:07 AM8/14/18
to v8-users
I have a similar problem when embeding V8  6.8 to android.  An error is reported while linking libv8_nosnapshot.a, briefly 

../../src/isolate.cc:0: error: undefined reference to 'vtable for v8::internal::SetupIsolateDelegate'

Can anyone help, please.

在 2018年4月13日星期五 UTC+8下午6:37:57,Coulson Chen写道:

ibon

unread,
Aug 15, 2018, 9:04:49 AM8/15/18
to v8-users
I avoid linker problems by properly sorting the libraries.
The linker is sequential, and will fail if a given symbol is not present by the time it is referenced, regardless it is in another to link lib.

This is a sort order that worked for me.
 v8_base v8_libplatform v8_libbase v8_libsampler v8_snapshot v8_inspector

Other than that, I now make one single lib file will all v8 code in it. Not only to avoid linker errors, but to make my life easier by substantially reducing my mk file size.

hope this helps.

Zac Hansen

unread,
Aug 15, 2018, 2:09:43 PM8/15/18
to v8-users
you can always just throw all the libs at the linker twice, too, if you're not sure the order..

young louis

unread,
Aug 17, 2018, 3:40:23 AM8/17/18
to v8-u...@googlegroups.com
Well, there is no linker problem if v8_snapshot is used. Linker problem for v8_nosnapshot only. 

As for the libs order, I  used a combined library created by the following commands bellow. Order had been adjusted. Not working.


ar -rcsD libv8_base.a ../v8_base/*.o
ar -rcsD libv8_base.a ../v8_libplatform/*.o
ar -rcsD libv8_base.a ../v8_libbase/*.o
ar -rcsD libv8_base.a ../v8_libsampler/*.o
ar -rcsD libv8_base.a ../src/inspector/inspector/*.o


Zac Hansen <xax...@gmail.com> 于2018年8月16日周四 上午2:09写道:
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hyper

unread,
Aug 17, 2018, 1:33:48 PM8/17/18
to v8-users
SetupIsolateDelegate is defined in v8’s setup-isolate.h file and has no dependencies. Have you tried including it ?

Coulson Chen

unread,
Aug 20, 2018, 2:51:46 AM8/20/18
to v8-users
Yes, using  libv8_snapshot.a instead of  libv8_nosnapshot.a can work . I hava a another problem : building with v8 6.8 version can't generate snapshot library while 6.5 can generate, I using the same config and as the official wiki said, snapshot is built by default.

在 2018年8月17日星期五 UTC+8下午3:40:23,young louis写道:

young louis

unread,
Sep 6, 2018, 2:55:11 AM9/6/18
to v8-users
For version 6.8, v8_snapshot should be built by default but it isn't . The following configure solves the problem. Give it a try. 
'''
is_component_build = false
is_debug = false
symbol_level = 1
target_cpu = "arm"
target_os = "android"
use_goma = false
v8_android_log_stdout = true
v8_static_library = true
v8_use_external_startup_data = false
'''
Save and compile. 


在 2018年8月20日星期一 UTC+8下午2:51:46,Coulson Chen写道:
Reply all
Reply to author
Forward
0 new messages