Skip to content

Fails to link on Windows, how is libz supposed to be linked? #21

@KarelPeeters

Description

@KarelPeeters

I get the following error when trying to build this crate with the default features:

   Compiling highs-sys v1.6.0 (C:\Documents\Programming\Contrib\highs-sys)
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX64\\x64\\link.exe" [...]
  = note: highs.lib(HMpsFF.obj) : error LNK2019: unresolved external symbol deflateEnd referenced in function "public: virtual void * __cdecl zstr::istreambuf::`scalar deleting destructor'(unsigned int)" (??_Gistreambuf@zstr@@UEAAPEAXI@Z)
          highs.lib(HMPSIO.obj) : error LNK2001: unresolved external symbol deflateEnd
          highs.lib(reader.obj) : error LNK2001: unresolved external symbol deflateEnd
          highs.lib(HMpsFF.obj) : error LNK2019: unresolved external symbol inflate referenced in function "public: virtual int __cdecl zstr::istreambuf::underflow(void)" (?underflow@istreambuf@zstr@@UEAAHXZ)
          highs.lib(HMPSIO.obj) : error LNK2001: unresolved external symbol inflate
          highs.lib(reader.obj) : error LNK2001: unresolved external symbol inflate
          highs.lib(HMpsFF.obj) : error LNK2019: unresolved external symbol inflateEnd referenced in function "public: virtual void * __cdecl zstr::istreambuf::`scalar deleting destructor'(unsigned int)" (??_Gistreambuf@zstr@@UEAAPEAXI@Z)
          highs.lib(HMPSIO.obj) : error LNK2001: unresolved external symbol inflateEnd
          highs.lib(reader.obj) : error LNK2001: unresolved external symbol inflateEnd
          highs.lib(HMpsFF.obj) : error LNK2001: unresolved external symbol deflateInit2_
          highs.lib(HMPSIO.obj) : error LNK2001: unresolved external symbol deflateInit2_
          highs.lib(reader.obj) : error LNK2001: unresolved external symbol deflateInit2_
          highs.lib(HMpsFF.obj) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function "public: virtual int __cdecl zstr::istreambuf::underflow(void)" (?underflow@istreambuf@zstr@@UEAAHXZ)
          highs.lib(HMPSIO.obj) : error LNK2001: unresolved external symbol inflateInit2_
          highs.lib(reader.obj) : error LNK2001: unresolved external symbol inflateInit2_
          C:\Documents\Programming\Contrib\highs-sys\target\debug\deps\highs_sys-cfaabb362e14e905.exe : fatal error LNK1120: 5 unresolved externals


error: could not compile `highs-sys` (lib test) due to previous error

This makes sense, HiGHS requires zlib to be linked trough the zstr external dependency, and zlib is not linked by default. Enabling the zlib feature fixes this issue, but now the error is

error: could not compile `highs-sys` (test "test_highs_call") due to previous error
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX64\\x64\\link.exe"  [...]
  = note: LINK : fatal error LNK1181: cannot open input file 'z.lib'

Again, this makes sense since nothing in the build script or in the cloned submodule HiGHS includes the file z.lib.

My questions:

  • Why is zlib a feature that is not turned on by default? Is there ever a scenario in which we don't want to link zlib?
  • How is the built supposed to be getting zlib on Windows? Should I just install it separately and add it to the path? That seems a bit suspicious. Maybe it would be better to add a dependency on https://github.com/rust-lang/libz-sys, or at least to copy their machanism for finding zlib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions