It's possible that it works prior to version 3.10, but that's the minimum I've tested with (Ubuntu 18.04 has cmake v3.10 in its package manager). One thing to keep in mind is that I currently require version 3.10 of CMake. There are almost certainly still some sharp corners in cmake-cargo - I'm still hacking on it and wasn't quite ready to share it publicly, but this post was such a perfect prompt, I couldn't help but share! So, if you can kick the tires, please file any issues you run into. recursive to get the cmake-cargo submodule), and give it a try and let me know if it works for you! Please, go ahead and clone my fork (remember to use git clone. I was able to build successfully with both the shared and static lib on both Windows and Ubuntu (using WSL, but shouldn't be any different on real Ubuntu). I went through and commented up the CMakeLists.txt file explaining exactly how to integrate. I went ahead and forked your project here and modified it to use cmake-cargo. I actually also had your exact scenario of using "cbindgen" to generate the header files from my Rust lib. In fact, I used the project all last week in a hackathon, running into essentially zero issues with it, allowing me to hack pretty efficiently on my project, never having to deal with integration-related build issues. I've been working on a project called cmake-cargo for easily integrating a cargo project into CMake, automatically exposing targets for all executables, static libs, and shared libs that the imported Cargo Workspace contains. The good news is there's an easier way to do it! Shameless is exactly right - you need to be careful about specifying the right native dependencies when linking rust libs statically. I've put together a GitHub repository with my code and a README explaining the issue in depth at the following link (and would be happy to post the text of the README here if that would be helpful). I'm interested in eventually being able cross-compile and move the resulting binaries to a different machine, so I think that compiling with a static lib would be the best way to go. a, I end up being unable to compile it, due to what looks like some sort of issue using the println!() macro. However, when I try to switch from using a dynamic library to a static one. that library is compiled and linked as a dynamic library. Everything seems to work quite well when I'm building this project s.t. I'm currently working on trying to integrate a Rust library into a C++ project using the CMake system. Hello! This is my first post here, so please bear with me if anything's out of line, and I'd appreciate any advice.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |