我正在写一个依赖于专有DLL的Haskell包。我还使用stack
工具。该库具有x86和x64版本。根据{{3}},我无法修改.cabal
文件。所以我试图通过更新Setup.hs
来做到这一点。这是我的设置脚本:
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
}
然后我打电话给:
> stack test
在测试套件链接期间,这仍会导致未定义的引用。为什么呢?
答案 0 :(得分:1)
只需两步:
"txmlconnector64.dll"
替换为"txmlconnector64"
.cabal
文件集build-type: Custom
中允许其使用您的Setup.hs