如何将包与专有DLL链接?

时间:2016-03-20 08:52:13

标签: haskell dll ghc cabal haskell-stack

我正在写一个依赖于专有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

在测试套件链接期间,这仍会导致未定义的引用。为什么呢?

1 个答案:

答案 0 :(得分:1)

只需两步:

  1. "txmlconnector64.dll"替换为"txmlconnector64"
  2. .cabal文件集build-type: Custom中允许其使用您的Setup.hs