Skip to content

Linking libstdc++ is broken on Windows

Foo.hs:

main = return ()

file.cpp:

#include <iostream>
extern "C" { void foo() { std::cout << "Hello\n"; } }

Building with:

ghc -o tst Foo.hs file.cpp -lstdc++

and then running tst.exe produces this:

tst.exe: error while loading shared libraries: libstdc++-6.dll:
cannot open shared object file: No such file or directory

Adding -optl-static makes the error go away. GHC doesn't seem to ship libstdc++-6.dll but does ship libstdc++-6.dll.a which might cause the problem.

Trac metadata
Trac field Value
Version 7.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information