cargo-dist icon indicating copy to clipboard operation
cargo-dist copied to clipboard

Windows linker errors in `cargo-dist` workflow: `warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library`

Open CramBL opened this issue 1 year ago • 3 comments

Summary

It seems that my build is statically linking HDF5 but not MSV CRT and that causes a problem?

I get a ton of errors like this:

libhdf5_metno_sys-afead0c756f87c12.rlib(H5EAstat.obj) : error LNK2001: unresolved external symbol __imp__wassert
libhdf5_metno_sys-afead0c756f87c12.rlib(H5FAstat.obj) : error LNK2001: unresolved external symbol __imp__wassert
libhdf5_metno_sys-afead0c756f87c12.rlib(H5HFdtable.obj) : error LNK2001: unresolved external symbol __imp__wassert

I want to

Statically link HDF5 because I absolutely don't want my users to have to find the right headers and I don't want to bundle them either, I need to not deal with that headache at all.

Works with how I normally build, see this CI run:

https://github.com/luftkode/logviewer-rs/actions/runs/11369355310/job/31626596049

NOTE: No HDF headers are manually installed, it is handled by the HDF5 crates builds.rs that fetches and statically links dependencies with cmake.

But with my release (cargo-dist) workflow

... the windows build fails: https://github.com/luftkode/logviewer-rs/actions/runs/11369355557/job/31626621637

I tried

Adding this .cargo/config.toml:

[build]
rustflags = ["-Ctarget-feature=+crt-static"]

does not change anything.

CramBL avatar Oct 16 '24 16:10 CramBL

Hmm, interesting. I'll review and get back to you.

mistydemeo avatar Oct 16 '24 16:10 mistydemeo

I don't fully understand the issue but after reproducing it on a windows machine I ended up disabling static linking of the VS CRT.

EDIT: That did not fix the issue still... I don't know why I thought it would.

So it seems that dist is attempting to statically link the CRT even though I don't specify that?

CramBL avatar Nov 12 '24 20:11 CramBL

This issue could be resolved by https://github.com/axodotdev/cargo-dist/issues/1782

CramBL avatar Mar 02 '25 14:03 CramBL