Michael-F-Bryan / rust-ffi-guide

A guide for doing FFI using Rust
https://michael-f-bryan.github.io/rust-ffi-guide/
Creative Commons Zero v1.0 Universal
282 stars 18 forks source link

Use --lib to create a Cargo library #76

Closed fdb closed 6 years ago

fdb commented 6 years ago

Cargo's default target when creating a new project is a binary target, meaning a project with a main.rs. Since we want a library, we have to be explicit and use the --lib flag when initialising the project.

Michael-F-Bryan commented 6 years ago

Thanks @fdb! It looks like that section never got updated when cargo switched to --bin by default.

fdb commented 6 years ago

I had to make some more changes to make it work with the latest version of the dependencies + the Rust 2018 edition. I'm not sure if you want those as well, since it looks like you're working on a full rewrite.

I like this version since it integrates with Qt, which is exactly my use case as well and is super-useful.

Just let me know and I can send you some more PRs.

Michael-F-Bryan commented 6 years ago

What about contributing a small example of using interoperating between C++/Qt and Rust, similar to the chapter on wrapping libmagic?

The main reason behind a rewrite is to visit the different techniques and concepts associated with FFI instead of focusing on a single language and framework, but I think it's important to also have worked examples where you explain your thought process while trying to solve a real-world problem. That way people have a resource for binding to Qt without having to read through the 10 or so chapters in the current version.