Closed rubenlg closed 1 year ago
FTR: I'm downloading and building the latest stable version of V8, rather than using the libnode
package from Ubuntu (which includes libv8
as well). Will follow up with the results.
Turns out I can't build against the latest stable V8 because of #181.
I just noticed a class.ipp
file next to class.hpp
. Turns out I had to include that one, which is the one calling SetInternalFieldCount
to populate a pointer to the C++ instance inside the v8 one, otherwise it can't unwrap it.
So for others having this issue, the fix is to use this include:
#include <v8pp/class.ipp>
It would be great to have this documented somewhere. I ended up having to understand the V8 API in detail in order to arrive to this conclusion.
I tried following the official examples from the
README.md
and also the website (they are very similar) to wrap a class in v8pp. The class gets created correctly in JS, but when attempting to call a method (get
in this case) it crashes.Here is a minimal repro case. The v8 boilerplate is unavoidable, since I'm not making a node module.
Here is a stack trace taken from gdb (the useful part, since the rest is just ?? all the time):
I'm using the latest version of the v8pp code, I just downloaded it from github yesterday (2022-09-19). For v8, I'm using the libnode-dev library that comes with Ubuntu 22.04 (12.22.9~dfsg-1ubuntu3). I compiled with
clang++ -std=c++17
. My clang version is 14.0.0-1ubuntu1 (the clang that comes with the latest Ubuntu). Tried withg++
and got the exact same result and stack trace.The V8 version in ubuntu has the following
v8-version.h
file: