mrkkrp / zip

Efficient library for manipulating zip archives
Other
81 stars 27 forks source link

Linking error on `haskell-zip-app` #67

Closed ocramz closed 3 years ago

ocramz commented 4 years ago

When compiling a project that requires zip (both with stack 1.9 and 2.1.3) I get this:

    [1 of 1] Compiling Main             ( bench-app/Main.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/haskell-zip-app/haskell-zip-app-tmp/Main.o )
    Linking .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/haskell-zip-app/haskell-zip-app ...
    Undefined symbols for architecture x86_64:
      "_utimensat", referenced from:
          _cazW_info in libHSdirectory-1.3.3.0.a(Posix.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    `gcc' failed in phase `Linker'. (Exit code: 1)

Do you know a fix for this, or is there a way to not build the benchmark application if one only needs the zip library? Thank you!

mrkkrp commented 4 years ago

I cannot reproduce the problem here. What OS are you on?

ocramz commented 4 years ago

I'm on OSX Mavericks (10.9.5)

mrkkrp commented 4 years ago

It may be Mac specific then.

jeffstyr commented 4 years ago

I ran into a similar problem (on macOS 10.14.4, with stack 2.3.1). I'm not sure if it's the exact same, since in my case the linker was complaining about a different symbol, but I think it was due to the system libbz2 being too old, and being used by bzlib-conduit. (I'm not sure why the bzlib-conduit build was succeeding, though it was logging an linker warning too.)

My workaround was to install a newer bzip2 via:

brew install bzip2

And then add this to the stack.yaml in my project directory:

configure-options:`
  bzlib-conduit:
  - --extra-lib-dirs=/usr/local/opt/bzip2/lib

In the problem @ocramz reported here, it looks like the link failure is related to directory, so it might be something different.

saurabhnanda commented 3 years ago

For anyone else facing this, move to an LTS that has a compiler version LATER than 8.8.3. There was a bug in 8.8.3 related to macos, which was fixed later.