[Haskell-cafe] Add linker flags to GHC 6.12.3 using extra-gcc-opts

Shaun Jackman sjackman at gmail.com
Thu Oct 2 19:41:54 UTC 2014


Hi. I get the following error message when linking with GHC.

```
$ ghc -o hello-hs hello-hs.hs
/projects/btl/linuxbrew/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
```

It's fixed by adding `-L/projects/btl/linuxbrew/lib` to the command line.
```
$ ghc -L/projects/btl/linuxbrew/lib -o hello-hs hello-hs.hs
```

I'd like to add the above `-L` option to the default linking arguments
of GHC. I thought that I could do this by modifying the file
`extra-gcc-opts`. I changed it from ` -fwrapv` to ` -fwrapv
-L/projects/btl/linuxbrew/lib`, but it has no effect. I confirmed this
by changing it to ` -fBROKEN`, and again no effect. The file location
is `/projects/btl/linuxbrew/Cellar/ghc612/6.12.3/lib/ghc-6.12.3/extra-gcc-opts`.

How do I change the default gcc link options of GHC 6.12.3?

It would be difficult for me to upgrade to GHC 7.8.3 because the
binary package does not run on CentOS 5.11. Yes, I know it's ancient.
It's an HPC cluster, and I have no control over it. So, likewise, I'm
not able to install `libgmp-devel` in `/usr`, which would also solve
this issue.

Thanks for your help. Cheers,
Shaun

http://sjackman.ca


More information about the Haskell-Cafe mailing list