As a motivating example, I have a program where the logic is written in Haskell, but the GUI is written in C++ (using Qt). The Haskell code is compiled to a library, which can then be used by the C++ code. On Linux, it’s simple enough to do this by compiling the Haskell package to a shared library with -dynamic -shared -fPIC -fPIE -flink-rt
. By contrast, on Windows I’ve been compiling it to a static library instead (with -static -optl-static -staticlib
).
However, in the process of releasing a new version, today I tried recompiling it on Windows, and got a nasty error about relocation truncated to fit: R_X86_64_32
. Looking this up, apparently it means my static library has gotten too big to link easily — and since GHC doesn’t seem to support changing the code model, the obvious alternative would be to use dynamic linking on Windows too.
Which leads me to my question: what is the status of dynamic linking on Windows currently? The GHC User’s Guide suggests that it should be fairly simple to accomplish. But the relevant GHC Wiki article says there are problems with the ordinal value getting too large when the DLL has too many symbols. Normally I’d discount a 4-year-old article in favour of the current user’s guide… except that when I tried compiling to a DLL, I did indeed get an error message saying that the ordinals were too large. On Linux, each package is compiled to a separate .so
file, which keeps them fairly small, but when I try the same GHC options on Windows, it just complains that there are no 'dyn'
versions of the dependencies. Which would seem to indicate that it would work if I could compile the dependencies dynamically, but I can’t find any information on how to do so. This whole situation is quite confusing, and I would greatly appreciate some clarification on GHC’s support for compiling shared libraries on Windows.