Error while building v8 in android embedded
我试图将v8 7.6.90导入为我的Android NDK项目中的静态库,但是在链接过程中失败。
这是v8构建的
1 2 3 4 5 6 7 8 9 10 11 12 | android_unstripped_runtime_outputs = true v8_use_external_startup_data = false is_debug = false symbol_level = 1 target_cpu ="arm" target_os ="android" use_goma = false v8_enable_i18n_support = false v8_static_library = true is_component_build = false v8_monolithic = true v8_android_log_stdout = true |
它确实编译了,编译后给了我
CMakeLists.txt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | cmake_minimum_required(VERSION 3.4.1) add_library(v8 STATIC IMPORTED) set_target_properties( v8 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libv8_monolith.a) add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). ${CMAKE_SOURCE_DIR}/src/main/cpp/native-lib.cpp) target_include_directories( native-lib PRIVATE ${CMAKE_SOURCE_DIR}/libs/include) find_library( # Sets the name of the path variable. log-lib # Specifies the name of the NDK library that # you want CMake to locate. log) target_link_libraries( # Specifies the target library. native-lib v8 # Links the target library to the log library # included in the NDK. ${log-lib}) |
build.gradle:
1 2 3 4 5 6 7 8 | externalNativeBuild { cmake { cppFlags"-std=c++0x" } } ndk { abiFilters"armeabi-v7a" } |
native-lib.cpp在https://chromium.googlesource.com/v8/v8/+/master/samples/hello-world.cc中运行相同的示例
但是ld总是抱怨该错误:
1 2 3 | ../../src/compiler/graph-visualizer.cc:0: error: undefined reference to 'vtable for std::__1::basic_ios<char, std::__1::char_traits<char> >' /Users/fredguo/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-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 error: undefined reference to 'v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, v8::platform::InProcessStackDumping, std::__ndk1::unique_ptr<v8::TracingController, std::__ndk1::default_delete<v8::TracingController> >)' |
我试图objdump我的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Disassembly of section .text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: 4: 81 b0 01 2b blhs #442884 <_ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE+0x6C210> Disassembly of section .rel.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: .rel.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: Disassembly of section .ARM.exidx.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: .ARM.exidx.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: Disassembly of section .rel.ARM.exidx.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: .rel.ARM.exidx.text._ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE: Disassembly of section .text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: _ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: Disassembly of section .rel.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: .rel.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: Disassembly of section .ARM.exidx.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: .ARM.exidx.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: Disassembly of section .rel.ARM.exidx.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: .rel.ARM.exidx.text._ZN2v811ArrayBuffer9Allocator19NewDefaultAllocatorEv: |
应该
但是,在错误消息中,ld尝试找到
我认为它们具有不同的名称空间,但是如何解决此问题? 我在这里https://groups.google.com/forum/#!topic/v8-users/Jb1VSouy2Z0找到了类似的问题,但是该解决方案对我不起作用。
尝试在
从
希望这可以帮助。