[Haskell-cafe] Haskell with C++: removing runtime dependencies on Windows 10.

14 views
Skip to first unread message

aditya siram

unread,
Jan 19, 2017, 5:19:08 PM1/19/17
to haskell-cafe
Hi,
I am trying to create an executable on Windows 10 with some Haskell->C++ bindings I wrote but having trouble getting rid of some runtime DLL dependencies. I'm currently compiling and linking using the MSYS2 and GHC environment that ships with Windows Stack installer but no matter what I do I end up with the following dependencies:
$ ldd <executable>
        ...
        libwinpthread-1.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libwinpthread-1.dll (0x64940000)
        libstdc++-6.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libstdc++-6.dll (0x6fc40000)
        libgcc_s_seh-1.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libgcc_s_seh-1.dll (0x61440000)

I have verified that the standalone versions of those libs are in available in stack install:
libstdc++:
  ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libstdc++.a
  ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libstdc++.dll.a
  ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc.a
libgcc:
  ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc_eh.a
  ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc_s.a
libpthread:
  ../stack/x86_64-windows/ghc-8.0.1/mingw/x86_64-w64-mingw32/lib/libpthread.a
  ../stack/x86_64-windows/ghc-8.0.1/mingw/x86_64-w64-mingw32/lib/libpthread.dll.a

I've unsuccessfully tried to link them into the executable using many combinations of `-optl-static`, `-optl-static-gcc`, and `-optl-static-stdc++` and also passing along these libraries "
raw" to the linker like:
`ghc-Options: -pgml g++ "-optl-Wl,--whole-archive" "-optl-Wl,-Bstatic" "-optl-Wl,-lstdc++" "-optl-Wl,-Bdynamic" "-optl-Wl,--no-whole-archive"

Short of shipping these DLL with the executable (which I'd really rather not do) I'm running out of ideas so any suggestions would be appreciated.
Thanks!
-deech

David Banas

unread,
Jan 20, 2017, 9:43:44 AM1/20/17
to Haskell Cafe
Hi Deech,

Not sure this is helpful, as I haven’t tested it on Windows 10, but here are the gcc/ghc compile/link options I use for a project that has a similar need:

CC = gcc
CFLAGS += -I/usr/lib/ghc-7.4.2/include/ -g -fPIC

HC = ghc
HC_OPTS = -cpp -O3 $(EXTRA_HC_OPTS)
EXTRA_HC_OPTS = -package parsec -dynamic -fPIC -rtsopts
HC_LOPTS = -shared -dynamic -package parsec -lHSrts -lm -lffi -lrt

-db

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

Reply all
Reply to author
Forward
0 new messages