-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fatal error: 'memory' file not found #3
Comments
Hello, The The error looks like the Assuming you didn't move files, you can dive into what's going on by setting the That'll then proceed to tell you the (possibly long) command it's running to call out to the A quick try would be to add the path to your system includes using This is however an artifact of bindgen not having a MacOS port. Afaik, the On that note, does it work at all? Is the test suite running (Standard |
This is what I get when I run it with VERBOSE=1
I can't run using the
|
As for the spec, I got this:
Pretty good! |
That whole thing there is the invocation command of the clang part. Instead of
you can also just give it the path to your If you can get that command to run, you'll get bindgen to work. So that's what you want to focus on. You can check
With that we could come up with what to do next. |
Ok, adding the resource-dir option fixed it, but the JSON is full of empty objects:
|
With that invocation that's an expected output. Bindgen doesn't "grab everything", only what you want it to. Please check the |
Oh nice, adding one class produced a big JSON output. I had to change the runner.cr to pass this argument I need to make it work with the usage from the README. I'm not sure where I should add it in the build process so I don't have to change the bindgen package. It seems to work, there are a lot of coupling between classes in v8, I'm trying to find a simple class to get a "win" 😄Unfortunately I'm mostly getting errors likes:
Most types are going to be void pointers I believe. I tried inspiring from the qt5 shard you made, but I don't fully grasp how things are parsed yet. I added a bunch of ignored types in the v8.yml and brought it down to 2 errors, but it's hard to know what to do here.
I feel like it might be easiest to write a C bridge! Although Qt must've been a massive effort and you seem to have done it. |
The README is fun and all, but the main documentation is in the I don't know anything about v8 (beyond its existence), so I don't know how it's meant to be used. But I recommend adding the absolutely necessary classes, that you'll actually interact with, first. Ignore all other types, do so explicitly where necessary (You did this already it seems). And then iteratively add classes as you need them, cleaning up ignored types as you go.
Qt doesn't use namespacing, so that case may not be handled nicely yet. That error basically warns that bindgen (with that configuration) was about to generate a Crystal line like The CrystalBinding processor is responsible for generating these aliases in any case.
Is an artifact of the error above, but do have have explicitly ignored the locker type, while having it in the classes list? If so, then yeah it's unreachable, as it doesn't exist on the binding level. Locker by name, and the API snippets from above, make it seem like it's a RAII locker class? That'll be fun, I'd ignore it for now. RAII doesn't translate well to Crystal. You probably want to half-manually bind it in the long run to provide a Crystal native API on top of it instead of passing it through directly. I do this in a few places in Qt as well.
Yeah, that's what bindgen does for you. Take a look in the generated .cpp file (Just remove the However, if there is a good C bridge, you could bind to that instead. Bindgen also has facilities to deal with C libraries. Consult the |
Thanks, that helps! Looks like it's working well. The TEMPLATE has great comments, but I didn't know what I didn't know before, meaning I didn't know what to make of a lot of the comments in there. Now they make more sense. While I've got you here, I'm not sure how to add a container like I've added: containers:
- class: v8::Local
type: Sequential
classes:
# ...
v8::Local: Local
types:
# ...
v8::Local:
crystal_type: Local
binding_type: Local This template can contain a lot of different types, most commonly it will be a I got the error:
Is there a way to get more info from the error? |
The template instantiation support is quite in its beginnings, as I simply didn't need it much with Qt (Qt was the driving factor behind bindgen after all). A While that feature would be neat, I don't have the time right now to work on it. What you can do however is providing custom conversion code to go from a Oh and when you add In general, that Basically a fully custom conversion goes like this:
W.r.t. 5), Set the That's so complex that I don't think a wrapper generator could auto-generate a good API that people would like. Bindgen can help you get the tedious bits done, though for such complex cases, you'll end up writing a few lines. |
Yes, I think a converter would do the trick. I think there are issues with the v8 namespacing. If I don't manually write those I wasn't expecting perfect bindings generation, this shard already surpasses my wildest dreams ;) I have a feeling it's generating the right structs and functions. We'll see once I can actually try it out (I can't until I have v8::Platform done at least, which is fairly contained, so it should be quick enough.) Any tips for |
Oh shit. Well, that's going to be nasty. First there's the issue with there not being proper template instantiation support that's going to bite you here. (Although I think for this having a "smart pointer" specialization as there is for sequential containers would be neat, as that idiom is all over the place in C++). That aside, the bigger issue is mixing the ownership model of C++ (Well, You'd have to rip out the object pointer from the Crystal container class, and then in the We can fix/add stuff to deal with smart pointers, maybe even special rules for shared/unique smart pointers. But we can't fix the user. I'm honestly not sure how to properly bridge this. Do you know how other bindings (maybe for other GC'd languages) deal with this? |
There are basic golang bindings here (they work well): https://github.com/augustoroman/v8 As far as I understand, he wraps those pointers in its own pointers and then passes those back and forth. Go is GCed, but it doesn't do bindings the same way that Crystal does. That's the C bridge I might decide to use. Except I may just use that package and golang instead of writing bindings at all! |
Would using a C bridge similar to https://github.com/augustoroman/v8 help? I expect I'd run into the same problems with pointers getting freed. However, it probably would be a simpler bridge given the nicer bindings API in Crystal. |
As long no one feels like implementing smart pointer support, using a wrapper that "hides" them will help. Bindgen has facilities to wrap C libraries back into classes. |
Note: I've successfully got bindgen to work under macos. I had to modify the scripts a bit, but I was able to compile clang and everything. I just couldn't get
-ltinfo
, I just removed it for now.I don't think I'll succeed, but I'm trying to generate bindings for libv8.
One of the first things it includes is
<memory>
. Which is part of the stdlib. My .yml config looks like this:I get the following error:
How can I make this work? I tried adding
memory.h
to my files and it didn't work.The text was updated successfully, but these errors were encountered: