Runtime linker doesn't search for DLLs referenced in import libraries on Windows
(This is adapted from the comments here.)
On Windows, the GHC runtime linker only searches for DLLs that have the same names as the import libraries passed to -l
. This can sometimes create problems, since a library name could be different from the DLL it needs.
text-icu
provides an example of this, since it needs the extra libraries icuuc
, icudt
, and icuin
. However, if you download the official ICU 56 binaries, they are distributed with DLLs named icuuc56.dll
, icudt56.dll
, and icuin56.dll
, rather than icuuc.dll
, icudt.dll
, and icuin.dll
.
This doesn't create any trouble for the linker at compile-time. In fact, if you compile this program
-- TextICU.hs
import Data.Text.ICU.Break
main = print Kana
with ghc TextICU.hs
and then run cygcheck ./TextICU.hs
without having the ICU4C bin64
folder in your PATH
, it appears to search for the right DLLs:
$ cygcheck ./TextICU.hs
...
cygcheck: track_down: could not find icuin56.dll
cygcheck: track_down: could not find icuuc56.dll
But actually running the code reveals a different story:
$ runghc TextICU.hs
TextICU.hs: icuuc: The specified module could not be found.
TextICU.hs: <command line>: can't load .so/.DLL for: icuuc.dll (addDLL: could not load DLL)
This demonstrates that the runtime linker behaves differently; it is dependent on what the linked libraries' names are. To confirm this, you can recompile text-icu
with the following changes to text-icu.cabal
:
extra-libraries: icuuc56
if os(mingw32)
extra-libraries: icuin56 icudt56
Also make symlinks named icuuc56.lib
, icuin56.lib
, and icudt56.lib
that refer to icuuc.lib
, icuin.lib
, and licudt.lib
, respectively, in the ICU4C lib64
directory. Now cygcheck
and ghc
agree on which DLLs to use:
$ ghc TextICU.hs
$ cygcheck ./TextICU.exe
...
cygcheck: track_down: could not find icuin56.dll
cygcheck: track_down: could not find icuuc56.dll
$ runghc TextICU.hs
TextICU.hs: icuuc56: The specified module could not be found.
TextICU.hs: <command line>: can't load .so/.DLL for: icuuc56.dll (addDLL: could not load DLL)
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.2-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Linking) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | YitzGale |
Operating system | |
Architecture |