I'm trying to use ghci / stack repl
on a project where one module has foreign calls linked to a C lib tdsodbc
, but I keep getting
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64-unknown-linux):
Loading temp shared object failed: /tmp/ghc4628_0/libghc_71.so: undefined symbol: SQLPrepareW
(where SQLPrepareW
is defined in that C lib). Building with stack works fine. This happens even on other modules that just happen to import the foreign-calling module, even without actually calling the foreign functions. It doesn't happen on load, but as soon as I try to fully evaluate any function in the repl.
How can I tell ghci that some of the functions are defined in libs outside of ghc?
I've tried the -l
option (e.g. stack exec ghci -- -ltdsodbc
), but the only difference then is that a different function from the same lib is in the error message:
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.3 for x86_64-unknown-linux):
Loading temp shared object failed: /tmp/ghc24107_0/libghc_25.so: undefined symbol: SQLDriverConnectW
Note that it's obviously checking for the lib when using -l
, since if I misspell it, it'll say it can't find it:
$ stack exec ghci -- -L/usr/lib/x86_64-linux-gnu/odbc -ltdsodbctypo
Warning (added by new or init): Specified resolver could not satisfy all dependencies. Some external packages have been added as dependencies.
You can suppress this message by removing it from stack.yaml
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
<command line>: user specified .o/.so/.DLL could not be loaded (libtdsodbctypo.so: cannot open shared object file: No such file or directory)
Whilst trying to load: (dynamic) tdsodbctypo
Additional directories searched: /usr/lib/x86_64-linux-gnu/odbc
This is with
$ stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
I've also tried stack ghci --ghci-options '-ltdsodbc -fobject-code'
, but it also panics with undefined symbol: SQLPrepareW
.
other-modules
, but even after adding and doingstack clean && stack build && stack ghci
it still panics just as before :( – unhammernm libtdsodbc.so | grep SQLDriverConnectW
show? – n. 1.8e9-where's-my-share m.$ nm libtdsodbc.so␍ nm: libtdsodbc.so: no symbols
but$ strings libtdsodbc.so|grep SQLDriverConnectW␍ SQLDriverConnectW
(and it compiles and runs fine with ghc, just not in ghci) – unhammerstrings
is not interesting, usenm -D
. – n. 1.8e9-where's-my-share m.