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
Feature Request: enable outputting cxx.cc itself to the target directory #1131
Comments
I would prefer not to make this change, because what you've described sounds like a build system that does not understand C++ that depends on Rust that depends on C++, not anything specific to how cxx.cc is linked by the cxx crate. For example if one of cxx's dependencies, or a dependency of one of your other Rust dependencies, added a dependency on some piece of C++ code it needs, you'd be back to square 1. I don't believe that papering over this case in the way that you suggest would be beneficial. I know that better approaches are possible because other build systems don't appear to have difficulty with this case. |
@dtolnay The issue boils down to cc-rs defaulting to the MSVC /MD runtime library. Integrating cxx into a /MT static library is therefore impossible in the current state. This is configurable through the following cc-rs function, perhaps you could expose a way to allow the /MT library to be used https://docs.rs/cc/latest/cc/struct.Build.html#method.static_crt |
That is not something that would need to be exposed in cxx. You need to use |
You're right, I tried to pass that flag via .cargo/config.toml, but it failed silently when I passed it incorrectly and I thought it didn't help. Thanks for bringing it back to my attention and helping me get things working. |
@Racinettee how did you get |
@ultimaweapon we didn't do anything special in terms of flags or manual modifications if that's what you mean. we copy cxx.cc directly into a location in our source tree where our build system (visual c++) expects to find it. if it helps and you're also using visual c++ - we use the c++latest flag and we're on the v143 tool-chain now, but i dont imagine those matter too much, and nothing else stands out to me as particularly important to make it compile |
Thank you for the information. |
Hello
Recently I've integrated cxx into a legacy visual c++ application and had a couple of difficulties around linking. It seems that rust and also cxx use a specific version of the msvc runtime library that will cause many conflicts when you link statically - things along the lines of runtime library conflicts and _ITERATOR_DEBUG_LEVEL macros.
After trying to link to cxxbridge1.lib a couple of times using different settings what I ended up going with making my crate a cdylib and to also compile cxx.cc directly into my c++ project.
My suggestion for this issue is to add an option somewhere that will have cxx or cxx-build output cxx.cc alongside cxx.h in the target/cxxbridge output directory so that users of this project will have greater flexibility in how they integrate cxx their projects. Currently my solution isn't future proof - but if you were to accept this proposal then it would be.
The text was updated successfully, but these errors were encountered: