Thank you for your answer, Zac. 🙂

I see that Node.js uses libuv <https://github.com/libuv/libuv> to 
dynamically load native addons and link them with V8 on runtime. I was 
hoping that V8 alone provided this kind of functionality. However, a native 
Node.js addon seems like the next best option, so that's what I'm going to 
try next.


On Wednesday, September 20, 2017 at 10:31:45 PM UTC+3, Zac Hansen wrote:
>
> There's no way to compile native code that can connect to any version of 
> v8 - first of all v8 spans platforms where the code wouldn't even make 
> sense.  Second of all, there are ABI concerns across versions.  Lastly, 
> there's no way to simply connect arbitrary data to v8 that's linked in to 
> another program.
>
> At least, as far as I know.
>
> On Wednesday, September 20, 2017 at 9:12:52 AM UTC-7, Vangelis Ts. wrote:
>>
>> Related, follow-up question:
>>
>> I've been wondering whether I could prepare a Context with all the object 
>> and function templates of my library, save it in a binary file (like V8 
>> does with the startup snapshot) and then load it on demand, in order to 
>> gain access to my library's code in the currently executing context. Is 
>> that even possible?
>>
>> P.S.: I am sorry for asking many, possibly vague, questions. This is my 
>> first experience with V8 and I haven't been able to find a right and 
>> accurate solution yet, although I've read the V8 wiki on GitHub.
>>
>> ― Vangelis
>>
>>
>> On Wednesday, September 20, 2017 at 5:21:21 PM UTC+3, Vangelis Ts. wrote:
>>>
>>> Hello,
>>>
>>> I have written a C++ library and I would like to make it work like a 
>>> Node.js addon (see https://nodejs.org/api/addons.html#addons_c_addons), 
>>> but for V8.
>>>
>>> However, I am not sure what is the best way to do that. Some 
>>> thoughts/limitations are:
>>>
>>> 1. I would prefer to connect it directly with V8, without any extra 
>>> interfaces (like nbind, for example) or Node.js.
>>> 2. Compiling the library to JavaScript (e.g. using Emscripten) is not an 
>>> option.
>>> 3. Ideally, I would like to be able to load it in any instance of V8, 
>>> such as in Chrome, (maybe via the "require(…)" keyword, like a Node.js 
>>> addon?), so embedding the library with V8 and shipping it as an executable 
>>> would not be a neat choice. I also guess that this diminishes the option to 
>>> compile the library as a builtin V8 library function.
>>>
>>> I would really appreciate any suggestions you might have. 🙂
>>>
>>> ― Vangelis
>>>
>>>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to