I am completely stuck trying to get a stack build with a native library dependency to work on Windows. The concrete problem occurs with htaglib/TagLib, but I assume it’s a generic native dependency issue.
On Linux (Ubuntu), there’s no problem - I just installed the libtag
package via apt, added the dependency to my cabal file, added import line and some code to a .hs file, and the build worked just fine.
I’m neither familiar with C/C++ builds nor with Windows, so for the time being I wanted to avoid building TagLib from scratch and instead hoped to get away with grabbing the dlls from cygwin. So now I have libtag.dll
and libtag_c.dll
in C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin
, but I have no idea how to inject them into the build dependencies.
I have tried to refer to the containing folders (both the original cygwin location and a lib
folder in the project root) via extra-lib-dirs:
both in stack.yaml
and the global config.yaml
. I have come across this bug and tried the workaround using ghc-options: -L...
(as well as extra-lib-dirs:
) in the cabal file. I have experimented with all file separator variants: slash, back slash, double back slash.
Whatever I do, it boils down to one of two outcomes:
- If there is no
lib
folder in the project root, I get<command line>: can't load .so/.DLL for: tag_c.dll (addDLL: tag_c or dependencies not loaded. (Win32 error 126)) ghc.EXE: addLibrarySearchPath: C:\path\to\project\lib (Win32 error 2): Das System kann die angegebene Datei nicht finden.
(german locale, “system cannot find the file”)
- With a 'lib` folder present, I get
<command line>: can't load .so/.DLL for: C://path//to//project//lib/libtag_c.dll (addDLL: C:\\path\to\project\lib\libtag_c or dependencies not l)
I have run stack with -v --cabal-verbose
and I’m at least seeing the "-LC:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin"
(from the cabal file workaround) in the ghc args.
Does anybody have an idea what I’m doing wrong, or can somebody point me to a working minimalist example of a Windows stack build with native dependencies? (Again, probably doesn’t need to be TagLib, any native dependency will probably do.) Any help is appreciated.
Thanks and best regards,
Patrick