On Wed, Dec 4, 2024 at 6:00 AM Grant Upson <
grant...@gmail.com> wrote:
>
> Hi everyone,
>
> I'm trying to embed V8 into a C++ project currently and keep encountering issues when linking V8. Currently i'm following the instructions on
https://v8.dev/docs/embed and doing this on Linux. After building V8 with these parameters
>
>
> gn gen
out.gn/library --args='is_debug=false is_component_build=false v8_enable_i18n_support=false use_custom_libcxx=false is_clang=true v8_monolithic=true target_cpu="x64" v8_use_external_startup_data=false'
>
>
> and attempting to link to the libv8_monolith.a static library it throws a bunch of undefined reference errors to the standard library e.g.,
>
> ld.lld: error: undefined symbol: std::basic_ios<char, std::char_traits<char>>::init(std::basic_streambuf<char, std::char_traits<char>>*)
> >>> referenced by logging.cc
>
> I've setup my default compiler to use clang with the LLVM standard library and using nm have determined that V8 is being built with clang and the LLVM std library since it outputs std::__1:: function symbols.
>
> I've also forced libc++ to be used in the cmake project that is trying to link to the V8 library with cmake commands like so
>
> set(CMAKE_CXX_STANDARD_LIBRARIES "-stdlib=libc++")
> set(CMAKE_C_FLAGS "-stdlib=libc++")
> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
>
> I'm really at a loss at what could be causing this issue because both the library and my project should be using the same standard library. Any advice?
In your other email you didn't have use_custom_libcxx=false set. Did
you do a clean/full rebuild after changing it?
FWIW, I believe V8 links to libstdc++, not libc++, when
use_custom_libcxx=false. Or at least, it doesn't set -stdlib=... but
uses whatever your linker defaults to.