Giter VIP home page Giter VIP logo

Comments (5)

robmikh avatar robmikh commented on June 20, 2024 1

The original project that ran into this is meant to be a dll instead of an executable, and distributed by itself. In the future I'd like the the dll to be entirely Rust, but until then it has some C++ portions. For the time being I need to statically link the two together.

By default, Debug mode will compile using /MDd. Overriding that by compiling with /MD does resolve the linker issues, but this does put me halfway to building as Release. I also tried /MT for fun and got more linker errors than before.

I might try to play with the build.rs to build with /MDd (or possibly building as debug, I guess building as release with /MDd is just as arbitrary). How does this usually work in the Rust ecosystem? Is there a way to inform indirect dependencies of desired build configurations? I've only ever seen people read environment variables from their build.rs, but I also haven't seen too many of them.

Thank you so much for the quick reply! I can't believe I didn't think about the runtime library flags...

from spirv_cross.

retep998 avatar retep998 commented on June 20, 2024 1

Rust currently always uses the release CRT. It does not have the option to use the debug CRT. Every crate that builds C code therefore builds it with the release CRT and so trying to link the resulting staticlib into a C project using the debug CRT will cause a CRT mismatch.

from spirv_cross.

grovesNL avatar grovesNL commented on June 20, 2024

Interesting, thanks for reporting the issue!

The idea is that this crate builds the C++ library SPIRV-Cross as part if it's build. In order to do this it uses cc-rs in spirv_cross's build.rs.

I believe the default behavior when static linking on Windows would mean that /MT would be provided while building SPIRV-Cross, which statically links a particular version of the runtime library.

Could static linking be avoided in this case? (You should be able to use Rust and C++ together fine without static linking, but maybe you're considering distribution of the executable or something else)

Was the C++ executable built with /MT? I would try changing it on that side first if possible and seeing if it helps. Otherwise we can try adjusting the build.rs to pass different flags for the SPIRV-Cross (C++) portion while still building the spirv_cross (Rust) portion as a static library.

from spirv_cross.

robmikh avatar robmikh commented on June 20, 2024

Hmmm... after some quick experimenting it's not as simple as compiling SPIRV-Cross with /MDd. Unfortunately, I've had my fill of linker errors for the past couple of days and will probably just put up with building my dll with /MD for now. I may come back to this later.

Thanks for your help! Feel free to close this issue if you don't think it's necessary.

from spirv_cross.

robmikh avatar robmikh commented on June 20, 2024

Ah, that's good to know! In that case I'll close the issue.

Thanks, @retep998!

from spirv_cross.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.