[Haskell-cafe] Wrong install-name path for shared/dynamic C-library on OS X

Christiaan Baaij christiaan.baaij at gmail.com
Tue Nov 13 14:10:08 CET 2012

Dear List,

The context of my problem is the following:
- ghc-HEAD uses shared-library _only_ on OS X
- A cabalized package that builds a shared/dynamic C-library (GLFW-b)

And my problem is:
A dynamically linked Haskell library gets the wrong install-name for a C-library:

otool -L ~/.cabal/lib/GLFW-b-
   build/libglfw.dylib (compatibility version 1.0.0, current version 1.0.0)

All the other paths reported by 'otool -L' are absolute, while the C-library (libglfw.dylib) that was part of the Cabalized package is relative.
The problem presents itself when I now want to use the GLFW-b package:

Loading package GLFW-b- ... can't load .so/.DLL for: /Users/baaijcpr/.cabal/lib/GLFW-b- (dlopen(/Users/baaijcpr/.cabal/lib/GLFW-b-, 9): Library not loaded: build/libglfw.dylib
  Referenced from: /Users/baaijcpr/.cabal/lib/GLFW-b-
  Reason: image not found)

I can update the install-name to the correct path using:
install_name_tool -change build/libglfw.dylib @loader_path/libglfw.dylib libHSGLFW-b-

So my question are:
- Where does the original install_name path (build/libglfw.dyli) come from? 
- What should be specified in the .cabal and/or Setup.hs file so that the haskell library is installed using the _correct_ relative path?



More information about the Haskell-Cafe mailing list