rust-lang / rust-lang/libz-sys

Linking fails on Windows if other -sys crates link to the system zlib

Open
#56 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
138
Forks
88
PR merge metrics
No merged PRs in 30d

Description

I'm trying to compile something for Windows (using msvc), but I have a static link version of zlib on my include and lib paths. Other -sys crates link to the system installed zlib, but as libz-sys builds zlib again this leads to the following error:

  = note: liblibz_sys-aa3193a377538516.rlib(inflate.o) : error LNK2005: inflateCodesUsed already defined in libmozjs_sys-a5f33b0cb310126e.rlib(inflate.obj)
          liblibz_sys-aa3193a377538516.rlib(inflate.o) : error LNK2005: inflateValidate already defined in libmozjs_sys-a5f33b0cb310126e.rlib(inflate.obj)
          liblibz_sys-aa3193a377538516.rlib(deflate.o) : error LNK2005: deflateGetDictionary already defined in libmozjs_sys-a5f33b0cb310126e.rlib(deflate.obj)
          liblibz_sys-aa3193a377538516.rlib(adler32.o) : error LNK2005: adler32_z already defined in libmozjs_sys-a5f33b0cb310126e.rlib(adler32.obj)
          liblibz_sys-aa3193a377538516.rlib(crc32.o) : error LNK2005: crc32_z already defined in libmozjs_sys-a5f33b0cb310126e.rlib(crc32.obj)

Is it possible for libz-sys to use the system zlib if it's available? I think the call to zlib_installed should be just made on msvc as well and that's it, but I'm not sure if that's all there is to it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the zlib_installed check and the MSVC-specific build path, then reproduce the duplicate-symbol failure with another -sys crate providing zlib. Done means that an available system zlib is detected on MSVC and libz-sys no longer builds a conflicting copy.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.