I'm writing a Haskell package which depends on a proprietary DLL. I also use stack
tool. The library has x86 and x64 versions. According to this issue I can't do it by modifying .cabal
file. So I'm trying to do it by updating Setup.hs
. This is my setup script:
import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import System.Directory
updateExtraLibDirs :: LocalBuildInfo -> IO LocalBuildInfo
updateExtraLibDirs localBuildInfo = do
let packageDescription = localPkgDescr localBuildInfo
test = head $ testSuites packageDescription
testBuild = testBuildInfo test
dir <- getCurrentDirectory
print $ length $ testSuites packageDescription
return localBuildInfo {
localPkgDescr = packageDescription {
testSuites = [ test {
testBuildInfo = testBuild {
extraLibDirs = (dir ++ "\\lib") : extraLibDirs testBuild,
extraLibs = ("txmlconnector64.dll") : extraLibs testBuild
}
} ]
}
}
main = defaultMainWithHooks simpleUserHooks {
confHook = \a f -> confHook simpleUserHooks a f >>= updateExtraLibDirs
}
Then I call:
> stack test
This still leads to undefined references during the test suite linkage. Why?
Just two steps:
"txmlconnector64.dll"
with "txmlconnector64"
.cabal
file set build-type: Custom
to allow it to use your Setup.hs