Re: [Haskell-cafe] Dynamically linking frameworks on macOS (Ryan Trinkle)

You could provide a wrapper script around ghc to pass -dynamic automatically. Or when installing append alias ghc="ghc -dynamic" to their bashrc. Not elegant but it's probably easier than any other solution. On 06/24/2017 08:00 AM, haskell-cafe-request@haskell.org wrote:
Message: 1 Date: Fri, 23 Jun 2017 11:31:37 -0400 From: Ryan Trinkle
To: Haskell Cafe Subject: [Haskell-cafe] Dynamically linking frameworks on macOS Message-ID: Content-Type: text/plain; charset="utf-8" Hi everyone,
I'm trying to ensure that beginner-level code that uses reflex-dom can be built by simply calling 'ghc myFile.hs', provided that all the necessary libraries are available in ghc-pkg. This works on linux, but on macOS, it's currently necessary for the user to add '-dynamic' to the command line. In particular, without -dynamic, the linker fails to find "_OBJC_CLASS_$_NSURL", which is a symbol in the Foundation system framework. Apple doesn't support (and strongly discourages) statically linked executables[1], so it's not terribly surprising that this doesn't work.
Is there anything I can do to avoid the need for -dynamic here?
Thanks, Ryan
[1]https://developer.apple.com/library/content/qa/qa1118/_index.html

Ryan Trinkle wrote:
Is there anything I can do to avoid the need for -dynamic here?
Heh, I was finagling with this yesterday for different reasons (Arch removed static boot libs from GHC). I found that there's a pc_DYNAMIC_BY_DEFAULT flag in /usr/lib/ghc-*.*.*/platformConstants which turns on -dynamic by default. I can't say if this will break anything (Cabal in particular) though, given that "DynamicByDefault" does not seem to have received much dev attention in recent years.
participants (2)
-
Phil Ruffwind
-
Thomas Jakway