Skip to content

OSX: C shared library linked as relative #4183

Closed

Description

@domenkozar

I'm building https://github.com/serokell/rocksdb-haskell/ with just Nix and also with Stack (+Nix). Both fail to build even when rocksdb lib forder is passed correctly:

configureFlags: --verbose --prefix=/nix/store/8mlm6x003sj8781qf688qx031yjysa83-rocksdb-0.1.0 --libdir=$prefix/lib/$compiler --libsubdir=$pkgid --with-gcc=clang --package-db=/private/var/folders/v0/ydgx93x96375ws14_16p93gr0000gq/T/nix-build-rocksdb-0.1.0.
drv-1/package.conf.d --ghc-option=-optl=-Wl,-headerpad_max_install_names --disable-split-objs --enable-library-profiling --disable-profiling --enable-shared --enable-library-vanilla --enable-executable-dynamic --enable-tests --extra-include-dirs=/nix/sto
re/mj95pj47pjjmxgdzzfp2357zsylw9m3s-rocksdb-4.13/include --extra-lib-dirs=/nix/store/mj95pj47pjjmxgdzzfp2357zsylw9m3s-rocksdb-4.13/lib

Build fails as:

dyld: Library not loaded: librocksdb.4.13.dylib
  Referenced from: /private/var/folders/v0/ydgx93x96375ws14_16p93gr0000gq/T/nix-build-rocksdb-0.1.0.drv-1/rocksdb-haskell-0a5bced/dist/build/Database/RocksDB/C_hsc_make
  Reason: image not found
running dist/build/Database/RocksDB/C_hsc_make failed (exit code -5)
command was: dist/build/Database/RocksDB/C_hsc_make  >dist/build/Database/RocksDB/C.hs
note: keeping build directory _/private/var/folders/v0/ydgx93x96375ws14_16p93gr0000gq/T/nix-build-rocksdb-0.1.0.drv-1_

This is a masked error, really it doesn't find rocksdb library because it's not linked as absolute path:

$ $(which otool) -L /private/var/folders/v0/ydgx93x96375ws14_16p93gr0000gq/T/nix-build-rocksdb-0.1.0.drv-1/rocksdb-haskell-0a5bced/dist/build/Database/RocksDB/C_hsc_make                                                 
/private/var/folders/v0/ydgx93x96375ws14_16p93gr0000gq/T/nix-build-rocksdb-0.1.0.drv-1/rocksdb-haskell-0a5bced/dist/build/Database/RocksDB/C_hsc_make:
        librocksdb.4.13.dylib (compatibility version 0.0.0, current version 0.0.0)
        /nix/store/wngzdrk0b53q24b5infy1g2j4d5mh1mx-libiconv-osx-10.11.6/lib/libiconv.dylib (compatibility version 7.0.0, current version 7.0.0)
        /nix/store/f0m22bm6x14fq68jxnzw2w9dca83jfk7-gmp-6.1.1/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.1.0)
        /nix/store/qsq0qzfi0dib713a83adz70scf5m3z1a-Libsystem-osx-10.11.6/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

Following work around works that sets the path back to absolute:

LnL7/nixpkgs@6edec59

Activity

  1. LnL7 commented on Dec 20, 2016

    @LnL7

    /participate

  2. Ericson2314 commented on Dec 21, 2016

    @Ericson2314
    Collaborator

    Might this relate to relocatable builds?

  3. LnL7 commented on Dec 21, 2016

    @LnL7

    Possibly, is there some way to disable that? I'm also not sure how this would work outside of nix.

  4. domenkozar commented on Jan 3, 2017

    @domenkozar
    CollaboratorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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