在android embedded中构建v8时出错

在android embedded中构建v8时出错,android,c++,android-ndk,v8,Android,C++,Android Ndk,V8,我试图在Android NDK项目中将v8 7.6.90作为静态库导入,但在链接过程中失败 这是我的v8版本的args.gnconfig: 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

我试图在Android NDK项目中将v8 7.6.90作为静态库导入,但在链接过程中失败

这是我的v8版本的
args.gn
config:

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
它确实编译了,并给了我一个
libv8_巨石

CMakeLists.txt:

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:

externalNativeBuild {
    cmake {
        cppFlags "-std=c++0x"
    }
}
ndk {
    abiFilters "armeabi-v7a"
}
native-lib.cpp在中运行相同的示例

但ld总是抱怨错误:

../../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> >)'
\u zn2v88platform18新的默认平台EINS0\u 15idletask支持0\u 21进程堆栈转储文件st3\u 110unique\u ptrINS\u 17tracing controlleren3\u 14默认值\u deleteIS5\u EEEE

应该是

v8::platform::NewDefaultPlatform(int,v8::platform::IdleTaskSupport,v8::platform::InProcessStackDumping,std::u 1::unique_ptr)

但是,在错误消息中,ld尝试查找
std::\uu ndk1::unique\u ptr)


我认为它们有不同的名称空间,但如何解决这个问题呢?我在这里发现了类似的问题,但解决方案对我不起作用。

尝试在
v8/buildtools/third\u party/libc++/trunk/include/\u config
中修改名称空间宏:

\u LIBCPP\u CONCAT(\uuuu,\u LIBCPP\u ABI\u版本)
\u LIBCPP\u CONCAT(\uu ndk,\u LIBCPP\u ABI\u版本)


希望这能有所帮助。

我相信在args.gn中添加
use\u custom\u libcxx=false
会解决问题,请看,我也面临类似的问题。我尝试使用\u custom\u libcxx=false标志,但这对我没有帮助。有解决办法吗?这是我的错误日志。SampleNDK/app/src/main/cpp/hello jni.cpp:42:错误:未定义对“v8::platform::NewDefaultPlatform(int,v8::platform::IdleTaskSupport,v8::platform::InProcessStackDumping,std::\uu ndk1::unique\u ptr>”的引用。../buildtools/third\u party/libc++/trunk/include/memory:3586:错误:未定义对“std:\uu1::\uuuuuuuuuuuuuuuuuuuuuuu共享\uu弱”的引用:()“@BABASHANKER我按照文档的要求,设法降级到7.2并编译。但我没有发现7.2以上的任何运气。这是我在7.2中的
args.gn
is\u debug=true target\u cpu=“arm”target\u os=“android”v8\u android\u log\u stdout=false is\u component\u build=false android\u unstripped\u runtime\u outputs=false v8\u enable\u backtrace=true v8\u enable\u slow\u dchecks=true v8\u optimized\u debug=false use\u goma=false v8\u单片=true v8\u use\u external\u startup\u data=false
P.我不知道如何在注释中获得新行,抱歉格式不好:PT他的答案是正确的。我必须为一些v8 7.2+和v8 8.0也这样做。
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: