haskell - Cabal 在 Windows 上安装 PCRE-Light。 Extra-include-dirs/extra-lib-dirs 不起作用

标签 haskell mingw cabal

我使用的是MinGW+MSYS,

我添加了 extra-include-dirs、extra-lib-dirs,但似乎没有任何东西可以帮助 cabal 找到 PCRE 库。以下是我尝试过的一些命令行,以及下面的一些示例输出。

cabal install pcre-light --extra-include-dirs='C:\Program Files (x86)\GnuWin32\include' --extra-lib-dirs='C:\Program Files (x86)\GnuWin32\lib'
cabal install pcre-light --extra-include-dirs='/C/Program Files (x86)/GnuWin32/include' --extra-lib-dirs='/C/Program Files (x86)/GnuWin32/lib'
cabal install pcre-light --extra-include-dirs="/C/Program Files (x86)/GnuWin32/include" --extra-lib-dirs="/C/Program Files (x86)/GnuWin32/lib"

我不断得到一些类似的东西:

Resolving dependencies...
Notice: installing into a sandbox located at C:\Users\user\src\DBSite\dbsite\.cabal-sandbox
Configuring pcre-light-0.4.0.3...
Failed to install pcre-light-0.4.0.3
Last 10 lines of the build log ( C:\Users\user\src\DBSite\dbsite\.cabal-sandbox\logs\pcre-light-0.4.0.3.log ):
[1 of 1] Compiling Main             ( C:\Users\user\AppData\Local\Temp\pcre-light-0.4.0.3-9072\pcre-light-0.4.0.3\dist\dist-sandbox-6710ae14\setup\setup.hs, C:\Users\user\AppData\Local\Temp\pcre-light-0.4.0.3-9072\pcre-light-0.4.0.3\dist\dist-sandbox-6710ae14\setup\Main.o )
Linking C:\Users\user\AppData\Local\Temp\pcre-light-0.4.0.3-9072\pcre-light-0.4.0.3\dist/dist-sandbox-6710ae14\setup\setup.exe ...
Configuring pcre-light-0.4.0.3...
setup.exe: Missing dependency on a foreign library:
* Missing C library: pcre
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal.exe: Error: some packages failed to install:
pcre-light-0.4.0.3 failed during the configure step. The exception was:
ExitFailure 1

最佳答案

我真的需要回答这个问题,因为我想很多人都遭受过这个问题。请明确我的系统规范:Windows 7 64 位、GHC 7.8.3 64 位、cabal 1.20.0.3

可能的失败原因:

1。缺少 C 库

2.32 位库与 64 位 GHC 不兼容。

你需要做:

1。一家善良的公司 airesoft 使用 Microsoft Visual Studio 2008 构建了 PCRE。转到 http://www.airesoft.co.uk/pcre下载您想要的 PCR 或点击 http://www.airesoft.co.uk/files/pcre/pcre-8.33.zip下载8.33。 (有人可以将其上传到sourceforge吗?)

2。将文件名 pcre3.lib 更改为 pcre.lib ,将 pcreposix3.lib 更改为 pcreposix.lib (我想这个文件实际上不需要,但以防万一。)我复制了文件而不是直接重命名它,但我认为两种方式都可以.

3。根据 32 位或 64 位 GHC,您需要指定额外的库并包含。 pcre-light 需要 pcre.h 和 pcre.lib。在我的机器上我只是运行

cabal 安装 pcre-light --extra-lib-dirs=E:\\DOWNLOAD\\pcre-8.33\\lib\\x64 --extra-include-dirs=E:\\DOWNLOAD\\pcre-8.33\\inc

如果您的 GHC 是 32 位,您只需删除上述命令中的\\x64

4。当然,您需要将pcre3.dll添加到您的系统库路径中。我只是将其复制到 C:\Windows\System32 目录。 (我不确定您是否需要将其重命名为 pcre.dll,保留两者以防万一。确保您选择正确的文件,因为 32 位 dll 将在 64 位计算机上崩溃,反之亦然)打开您的 GHCi,您应该能够导入Text.Regex.PCRE.Light并尝试调用一些函数。

如果可能的话,我会尝试将文件合并到其中的 pcre-light 包中。 祝你好运

关于haskell - Cabal 在 Windows 上安装 PCRE-Light。 Extra-include-dirs/extra-lib-dirs 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26288139/

相关文章:

c - 以编程方式或使用 list (MinGW) 将 "Override high DPI scaling"设置为 "System (Enhanced)"

haskell - 在 Windows 7 上使用 cygwin 安装 Cabal-dev

haskell - 如何序列化/反序列化 HashMap ?

haskell - 如何为 Constant a b = Constant a 实现可折叠实例?

Haskell: (+1) 和 (\x->x+1) 有什么区别?

testing - 带有类型详细示例的 Cabal 测试套件

haskell - 使用沙箱时如何让 cabal 忽略全局包数据库

optimization - 如何正确使用GHC的SPECIALIZE pragma? (例如 : specializing pure function from monadic ones using Identity. )

c - 尝试使用 matlab 的 libmat.dll,但编译器无法识别库中的函数

qt - 在 qt creator(mingw 4.8 和 qt 5.3)中使用 c++11 功能时出现奇怪的错误