Skip to content

GHCi reports unknown symbols in Win32 when linking C and C++ libs

GHCi (win32, v8.0.1) gives strange unknown symbols when being run using a library that interfaces code written in C or C++. Compiled code runs fine.

As an example I use the eigen-2.1.6 package from hackage. However, it should be noted that I get a similar error message when trying to link a package that uses libgsl (gsl has been compiled with the mingw-gcc that ships with haskell-platform).

When I compile the little script from the eigen-manual on hackage

module Main where
  import Data.Eigen.Matrix
  import Data.Eigen.LA

  main = do
    let
        a :: MatrixXd
        a = fromList [[1,2,3], [4,5,6], [7,8,10]]
        b = fromList [[3],[3],[4]]
        x = solve ColPivHouseholderQR a b
    putStrLn "Here is the matrix A:" >> print a
    putStrLn "Here is the vector b:" >> print b
    putStrLn "The solution is:" >> print x

I get (as expected):

Here is the matrix A:
Matrix 3x3
1.0     2.0     3.0
4.0     5.0     6.0
7.0     8.0     10.0

Here is the vector b:
Matrix 3x1
3.0
3.0
4.0

The solution is:
Matrix 3x1
-2.0
1.0000000000000016
0.9999999999999988

However, when I try to run it in GHCi I get

GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( test.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
ghc.exe: C:/Program Files (x86)/Haskell Platform/8.0.1/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libstdc++.a: unknown
symbol `___emutls_get_address'

ghc.exe: Could not on-demand load symbol '___cxa_get_globals'

ghc.exe: C:/Program Files (x86)/Haskell Platform/8.0.1/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libstdc++.a: unknown
symbol `___cxa_get_globals'

ghc.exe: Could not on-demand load symbol '___cxa_begin_catch'

ghc.exe: D:\Users\U439644\AppData\Roaming\cabal\i386-windows-ghc-8.0.1\eigen-2.1.6-6ZlfU8NIal9qgw3j5GclW\HSeigen-2.1.6-6
ZlfU8NIal9qgw3j5GclW.o: unknown symbol `___cxa_begin_catch'

ghc.exe: unable to load package `eigen-2.1.6'

I tried the same on OS X using GHCi v8.0.1. There everything works as expected.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
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