[GHC] #12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs

#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs ------------------------------+--------------------------------- Reporter: pl | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Windows Architecture: x86 | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ------------------------------+--------------------------------- 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 {{{#!hs 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12496 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by pl): * failure: None/Unknown => GHC rejects valid program -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12496#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: #11072 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => closed * resolution: => duplicate * related: => #11072 Comment: Hi Thanks for the report. This will be fixed by #11072, In the mean time there are several ways to work around this. including editing the cabal file for `Eigen` to include `stdc++-6` instead of `stdc++`. This will get it to work in GHCi but the executable will need `libstdc++-6.dll` to work. As a side note, even if you do this, Eigen needs to #ifdef some posix calls that are named differently on Windows. e.g. `strdup` on Windows is `_strdup`. The compiled version works because mingw-w64 has them still defined under their deprecated names. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12496#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: #11072 | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * differential: => Phab:D2478 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12496#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs
-------------------------------------+-------------------------------------
Reporter: pl | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: GHCi | Version: 8.0.1
Resolution: duplicate | Keywords:
Operating System: Windows | Architecture: x86
Type of failure: GHC rejects | Test Case:
valid program |
Blocked By: | Blocking:
Related Tickets: #11072 | Differential Rev(s): Phab:D2478
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Tamar Christina
participants (1)
-
GHC