Skip to content

How to link a static lib (zlib) using cli options instead extra-libraries #5805

Closed
@jneira

Description

@jneira

Hi, i've tried to build the package hopenssl, including the test suite in windows. The steps i've followed were:

extra-include-dirs: X:\path\to\OpenSSL-x86_64\include
extra-lib-dirs: X:\path\to\OpenSSL-x86_64\lib
  • Download the lib with cabal get hopenssl-2.2.2
  • executing cabal new-build --enable-tests -v3

At first the build failed linking one of the executables tests:

 Linking C:\Users\Javier\dev\lang\eta\dhall\hopenssl-2.2.2\dist-newstyle\build\x86_64-windows\ghc-8.4.4\hopenssl-2.2.2\t\check-low-level-digest-api\build\check-low-level-digest-api\check-low-level-digest-api.exe ...
C:\Users\Javier\dev\lib\openssl-1.0.2j-fips-x86_64\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x59): undefined reference to `inflate'
C:\Users\Javier\dev\lib\openssl-1.0.2j-fips-x86_64\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xea): undefined reference to  `deflate'
.... lot of undefined refs of zlib.c ...
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
cabal: Failed to build test:check-high-level-digest-api from hopenssl-2.2.2.
Failed to build test:check-low-level-digest-api from hopenssl-2.2.2.

Then i tested to add the z lib in the extra-libraries section of the cabal file and it worked, without pointing to zlib location explicitly (full log).

However it seems the package shouldn't add the lib, cause it is a specific issue of the concrete openssl lib implementation used in this case.
So i thought the solution could be to add the -lz option cause in the succesful case i detected it was being passed to hsc2hs and gcc (but no to ghc, at least explicitly). However i had not luck passing -lz in --gcc-options, --ghc-options, --ld-options, etc. (full log of cabal new-build --enable-tests --gcc-options=-lz)

Note: The build of hackage2nix executable of cabal2nix package fails with the same error. That is my primary goal (see NixOS/cabal2nix#389)
Thanks in advance!

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