
#10442: Loading of shared libraries is problematic in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: | Owner: artella.coding | Status: new Type: bug | Milestone: 7.10.2 Priority: high | Version: 7.10.1 Component: Compiler | Operating System: Linux Keywords: | Type of failure: Runtime crash Architecture: x86_64 | Blocked By: (amd64) | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Suppose that I have : {{{#!hs //test.h int add(int a, int b); }}} {{{#!hs //test.c int add(int a, int b){ return (a + b); } }}} {{{#!hs //mylib.c #include "test.h" int testAdd(){ return add(2,3); } }}} Then I compile via : {{{#!hs gcc -shared -o libtest.so test.c gcc -fPIC -c mylib.c -o mylib.o gcc -shared -o libMy.so mylib.o }}} Then I have Main.hs with : {{{#!hs module Main where import Foreign.C.Types foreign import ccall "testAdd" c_testAdd :: CInt -> CInt -> IO (CInt) main = do result <- c_testAdd 3 4 print result }}} and I have the associated cabal file : {{{#!hs name: illustrate version: 0.1.0.0 build-type: Simple cabal-version: >=1.10 executable illustrate main-is: Main.hs build-depends: base >=4.8 && <4.9 default-language: Haskell2010 extra-lib-dirs: ./ ghc-options: -ltest -lMy }}} Then upon running "cabal repl" I get the following error message (in ghc 7.10.1) : {{{#!hs *Main> main /home/linux/programs/ghc-7.10.1/lib/ghc-7.10.1/bin/ghc: symbol lookup error: ./libMy.so: undefined symbol: add }}} If I do "cabal run" I get : {{{#!hs Preprocessing executable 'illustrate' for illustrate-0.1.0.0... [1 of 1] Compiling Main ( Main.hs, dist/build/illustrate /illustrate-tmp/Main.o ) Linking dist/build/illustrate/illustrate ... Running illustrate... /home/linux/Downloads/illustrate/dist/build/illustrate/illustrate: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory }}} Note that in ghc 7.8.3, cabal 1.22.0.0 it works fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10442 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler