foreign libraries, dylibs, OS X Mavericks and GHC 7.8.3 woes

Hello Cafe, I will let this gist talk for me: https://gist.github.com/adinapoli/d4c33a9d1ea85bcaebdf Even though there is a solution, it seems extremely unsatisfying having to specify such paths manually. I always had very good experiences with FFI, OS X and GHC in the past, so this strikes me as a surprise. I have read a bit here and there about GHC 7.8.3 introducing the -dynamic flag (not sure about the specific problem it aims to solve, though) and changing some internal when it comes to library linking, but information is scattered and fragmented. I would like to: 1) Shed some light on my specific use case: Can I do better here? (aka have GHC figure out automatically all the nitty gritty details) 2) Any sort of pointers to documentation, tutorials, papers, everything to "teach me to fish”? Many thanks, Alfredo

Sounds like snappy isn't doing the right linking on its side. Might be a
bug there?
On Oct 14, 2014 6:42 AM, "Alfredo Di Napoli"
Hello Cafe,
I will let this gist talk for me:
https://gist.github.com/adinapoli/d4c33a9d1ea85bcaebdf
Even though there is a solution, it seems extremely unsatisfying having to specify such paths manually. I always had very good experiences with FFI, OS X and GHC in the past, so this strikes me as a surprise. I have read a bit here and there about GHC 7.8.3 introducing the -dynamic flag (not sure about the specific problem it aims to solve, though) and changing some internal when it comes to library linking, but information is scattered and fragmented. I would like to:
1) Shed some light on my specific use case: Can I do better here? (aka have GHC figure out automatically all the nitty gritty details) 2) Any sort of pointers to documentation, tutorials, papers, everything to "teach me to fish”?
Many thanks, Alfredo _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Carter, Thanks for answering. It's strange though, as that linker symbol refer to the cbits overlay (aka the foreign code Bryan wrote to call Snappy from Haskell) What am I missing ? Thanks! Alfredo Sent from my iPad
On 14/ott/2014, at 15:59, Carter Schonwald
wrote: Sounds like snappy isn't doing the right linking on its side. Might be a bug there?
On Oct 14, 2014 6:42 AM, "Alfredo Di Napoli"
wrote: Hello Cafe, I will let this gist talk for me:
https://gist.github.com/adinapoli/d4c33a9d1ea85bcaebdf
Even though there is a solution, it seems extremely unsatisfying having to specify such paths manually. I always had very good experiences with FFI, OS X and GHC in the past, so this strikes me as a surprise. I have read a bit here and there about GHC 7.8.3 introducing the -dynamic flag (not sure about the specific problem it aims to solve, though) and changing some internal when it comes to library linking, but information is scattered and fragmented. I would like to:
1) Shed some light on my specific use case: Can I do better here? (aka have GHC figure out automatically all the nitty gritty details) 2) Any sort of pointers to documentation, tutorials, papers, everything to "teach me to fish”?
Many thanks, Alfredo _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Alfredo, I will let this gist talk for me:
1) Shed some light on my specific use case: Can I do better here? (aka have
GHC figure out automatically all the nitty gritty details)
You're installing into a cabal sandbox and compiling directly with ghc (not cabal), but ghc doesn't know anything about the sandbox. You need to point it to the package database with -package-db and tell it the package for linking with -package [2]. $ ghc -package-db .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package snappy HelloSnappy.hs Linking HelloSnappy ... $ ./HelloSnappy HelloSnappy: foo.jpg: openBinaryFile: does not exist (No such file or directory) [1] http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#packag... [2] http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#... Regards, Sean

Hi Alfredo,
I will let this gist talk for me:
https://gist.github.com/adinapoli/d4c33a9d1ea85bcaebdf
1) Shed some light on my specific use case: Can I do better here? (aka
have GHC figure out automatically all the nitty gritty details)
You're installing into a cabal sandbox and compiling directly with ghc (not cabal), but ghc doesn't know anything about the sandbox. You need to
$ ghc -package-db .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package snappy HelloSnappy.hs Linking HelloSnappy ... $ ./HelloSnappy HelloSnappy: foo.jpg: openBinaryFile: does not exist (No such file or
Hi Sean,
I suspected sandboxing was involved!
Thanks for the pointer :)
Alfredo
On Tuesday, 14 October 2014, Sean Leather
[1] http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#packag... [2] http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#... Regards, Sean

You're installing into a cabal sandbox and compiling directly with ghc (not cabal), but ghc doesn't know anything about the sandbox. You need to point it to the package database with -package-db and tell it the package for linking with -package [2].
$ ghc -package-db .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package snappy HelloSnappy.hs Linking HelloSnappy ... $ ./HelloSnappy HelloSnappy: foo.jpg: openBinaryFile: does not exist (No such file or directory)
Alternatively, if you've got a recent version of cabal you can use cabal exec -- ghc HelloSnappy.hs instead. You can also load up GHCi in the sandbox using `cabal exec ghci` or `cabal repl`. Chris

You're installing into a cabal sandbox and compiling directly with ghc (not cabal), but ghc doesn't know anything about the sandbox. You need to
Cheers Chris,
I have added your solution to the gist, for the future-me:
https://gist.github.com/adinapoli/d4c33a9d1ea85bcaebdf
A.
On Wednesday, 15 October 2014, Chris Wong
it to the package database with -package-db and tell it the package for linking with -package [2].
$ ghc -package-db .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d -package snappy HelloSnappy.hs Linking HelloSnappy ... $ ./HelloSnappy HelloSnappy: foo.jpg: openBinaryFile: does not exist (No such file or directory)
Alternatively, if you've got a recent version of cabal you can use
cabal exec -- ghc HelloSnappy.hs
instead.
You can also load up GHCi in the sandbox using `cabal exec ghci` or `cabal repl`.
Chris
participants (4)
-
Alfredo Di Napoli
-
Carter Schonwald
-
Chris Wong
-
Sean Leather