Closed khazaddum closed 1 year ago
This is due to a missing lower bound on aeson
, sorry. You will need aeson
version 2.1 or higher; it should also not be too difficult to modify foreign-rust
to support other versions; PR welcome! :-)
I was able to compile it through Stack by pinning aeson
, borsh
, vector
and generically
.
However, c2hs
is failing at processing the example:
$ c2hs ../rust-wrapper/rust_wrapper.h GettingStarted.chs
In file included from GettingStarted.chs.h:2:
../rust-wrapper/rust_wrapper.h:7:10: fatal error: cstdarg: No such file or directory
7 | #include <cstdarg>
| ^~~~~~~~~
compilation terminated.
c2hs: Error during preprocessing custom header file
This is due to the fact that the default for the generated header is C++, not C, and you need to override that. I could have sworn I mentioned this in the blog post but I didn't -- apologies. I've submitted a PR against the blog post to fix that, but meanwhile, here's the relevant new paragraph:
Finally, we need to configure cbindgen and tell it what kind of header file we want; we don't need to call it manually (cargo cbuild
will do that for us), but we do need to tell it that we want a C header file, not a C++ header file. Create a file called cbindgen.toml
in the project root (alongside Cargo.toml
) with the following three lines:
include_guard = "RUST_WRAPPER_H"
include_version = false
language = "C"
Incidentally, the code for the blog post is at https://github.com/well-typed/blogpost-purgatory , and you can find it there, too. (That's no excuse, I should have mentioned it in the blog post for sure, but it might help you get unstuck.)
Thanks for your questions!
I was able to compile and use the library using stack
.
I have a few more questions but it's no longer related to compiling the code, is there a better way to post the questions?
Hello,
I'm trying to follow this tutorial and I am getting this error trying to compile
haskell-foreign-rust
: