After searching through the codebase, I found something interesting. In thrid_party/android_ndk/cxx-stl/llvm-libc++/include/__config:
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__ndk,_LIBCPP_ABI_VERSION) #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } But in buildtools/third_party/libc++/trunk/include/__config: #ifndef _LIBCPP_ABI_NAMESPACE # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #endif #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_ABI_NAMESPACE _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD I think they are different from each other, as the first one should be "std::__ndk1", and the second one should be "std::__1". On Saturday, May 25, 2019 at 11:37:37 PM UTC+8, Jian Guo wrote: > > I tried to import v8 7.6.90 as a static library in my Android NDK project, > but it fails at the link process. > > Here is my args.gn config for v8 build: > 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 > > > It did compile and gave me a libv8_monolith.a after compiling, I started > to set up my Android project then. > > 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 runs the same example in > https://chromium.googlesource.com/v8/v8/+/master/samples/hello-world.cc > > But ld always complains about the error: > > 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> >)' > > I tried to objdump my libv8_monolith.a: > > objdump -D app/libs/armeabi-v7a/libv8_monolith.a | grep NewDefault >> > > > 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: > > >> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_EEEE >> > > > should be > > v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, > v8::platform::InProcessStackDumping, > std::__1::unique_ptr<v8::TracingController, > std::__1::default_delete<v8::TracingController> >) >> >> > However, in the error message, the ld tries to find > std::__ndk1::unique_ptr<v8::TracingController, > std::__ndk1::default_delete<v8::TracingController> >)' > > I think they have a different namespace, but how do I solve this problem? > I found a similar issue here > https://groups.google.com/forum/#!topic/v8-users/Jb1VSouy2Z0, but the > solution didn't work for me. > > Any ideas? Thanks for your help. > > P.S: > > NDK version in my Android Project: 19.1.53 > > -- -- v8-users mailing list v8-users@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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/6863eff5-7557-422d-a5f9-89a742c711ca%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.