-
Notifications
You must be signed in to change notification settings - Fork 366
Getting cxxbridge working in a cmake codebase #229
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
Comments
There has been some experimentation with CMake in #156; perhaps it would be useful as a starting point.
The generated cc file is not intended to include the generated header file. Is it necessary in your use case to be able to include it? I filed #230 to follow up with ifdefs.
The generated files and cxx.h are all in C++, whereas the definition for how to drop a Vec<u8> is something that can only be provided by Rust. The |
Thanks for the quick response @dtolnay I'll take a look at the cmake pr! I don't think it's necessary in my use case I'm mainly just experimenting at the moment. |
Hello again @dtolnay, I have now managed to get everything setup in my company's cmake set up and got it compiling and working with calling Rust functions in C++ and sharing a struct containing a simple primitive type. I now tried to add |
The missing definitions you hit was definitely a bug -- #277. I released cxx 0.4.2 with the fix. |
I created an example setup to use cmake and cxx here Please let me know any issues and thanks for the great project! ❤️ |
I'll close out this issue as https://cxx.rs/build/cmake.html now provides two useful starter examples of CMake setups. |
Hello,
I'm a bit confused about the usage of the cxxbridge tool and I'm sure I've just misunderstood how to use it. I've tried to emulate the hello world example in this repo but my company is using cmake and this would be part of a much larger codebase so I tried to avoid using build.rs scripts. Our use case would be that we want to gradually replace an existing C++ code base with Rust so I want to link a Rust lib to the C++ executable.
First off both the header and cc file generated from my
lib.rs
file contains a definition of the shared struct which of course causes compile errors if I were to include the header in the cc file without adding ifdefs. The shared struct I've defined contains aVec<u8>
but none of the generated files created or thecxx.h
file in this repo contains a definition of the private methods such asdrop()
in the generated C++ code. Where is that definition expected to come from?The text was updated successfully, but these errors were encountered: