[GHC] #9348: "Symbol not found" when using a shared library
GHC
ghc-devs at haskell.org
Thu Jul 24 01:14:07 UTC 2014
#9348: "Symbol not found" when using a shared library
-----------------------------------------+----------------------------
Reporter: alex.davis | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version: 7.8.3
Resolution: | Keywords:
Operating System: MacOS X | Architecture: x86
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Revisions: |
-----------------------------------------+----------------------------
Comment (by alex.davis):
Shea Levy figured out the problem and its solution.
First of all, its not a problem with R, you get the same error from C.
I've attached Shea's C code, which I've titled "errorFromC.c". This code
tries to load the Haskell shared library, which it assumes is named
"test.dylib", and gives the same error as R.
Second, the problem is solved by adding to the compilation the flag
"-lHSrts-ghc7.8.3". This links the Haskell runtime system to the resulting
file.
(although, on my computer I still get errors due to the use if Int instead
of CInt in the Haskell code. But the problem of not being able to access
the Haskell code at all is solved.)
This represents a mismatch between the behavior of the compiler and its
documentation. People looking to make shared libraries will read
[https://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-
libs.html#idp12506320 section 4.13.3 of the GHC user's guide]. They will
see "To build Haskell modules that export a C API into a shared library
use the -dynamic, -fPIC and -shared flag". No mention of linking the
runtime system. I'm not sure if this a problem with the compiler or the
documentation, but either way it should be fixed.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9348#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list