Loading temp shared object failed when using template haskell and foreign functions #8466
Labels
Cabal: stanza/foreign-library
re: dynamic-linking
Concerning dynamic linking (e.g. flags "shared", "*-dynamic")
I'm working on a pet project which required a library written in c (tensorflow to be specific). I've written several c files which wrap the functions it provides in a more ffi friendly formats. My project compiles fine without template haskell.
If I try to splice, then when I compile, ghc comes up with this.
GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed
During interactive linking, GHCi couldn't find the following symbol:
/tmp/ghc550097_0/libghc_1.so: undefined symbol: TF_DeleteGraph
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
https://www.haskell.org/ghc/reportabug
After digging around for a while, I found this (#7082), which almost fix my problem except now ghc complain that it cannot find the c wrapper functions that I wrote.
The underlying problem seems to be that cabal doesn't pass the linker flags to ghc (both for the external library and object files that cabal compiles)
cabal 3.8.1.0
,ghc 9.2.2
, installed viaghcup
The text was updated successfully, but these errors were encountered: