GHC 的 zlib 构建错误
我正在使用具有以下配置的虚拟机:
- Arch Linux(3.0-ARCH 内核)
- GHC 7.0.3
- cabal-install 0.10.2
- Cabal 库 1.10.1.0
当我尝试使用 cabal 构建 zlib 时...
$ cabal install zlib
我得到以下输出:
Resolving dependencies...
Downloading zlib-0.5.3.2...
Configuring zlib-0.5.3.2...
Preprocessing library zlib-0.5.3.2...
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc: In function ‘main’:
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc:86:21: error: missing binary operator before token "("
compiling dist/build/Codec/Compression/Zlib/Stream_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c dist/build/Codec/Compression/Zlib/Stream_hsc_make.c -o dist/build/Codec/Compression/Zlib/Stream_hsc_make.o -fno-stack-protector -fno-stack-protector -D__GLASGOW_HASKELL__=700 -Dlinux_BUILD_OS -Dlinux_HOST_OS -Dx86_64_BUILD_ARCH -Dx86_64_HOST_ARCH -I/usr/lib/ghc-7.0.3/bytestring-0.9.1.10/include -I/usr/lib/ghc-7.0.3/base-4.3.1.0/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include/
cabal: Error: some packages failed to install:
zlib-0.5.3.2 failed during the building phase. The exception was:
ExitFailure 1
任何人都可以解释这个构建错误吗?
编辑:以下是 Stream.hsc 的一个片段,其中包含行号:
82 import Foreign
83 ( Word8, Ptr, nullPtr, plusPtr, peekByteOff, pokeByteOff, mallocBy tes
84 , ForeignPtr, FinalizerPtr, newForeignPtr_, addForeignPtrFinalizer
85 , withForeignPtr, touchForeignPtr )
86 #if MIN_VERSION_base(4,4,0)
87 import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )
88 import System.IO.Unsafe ( unsafePerformIO )
89 #else
90 import Foreign ( unsafeForeignPtrToPtr, unsafePerformIO )
91 #endif
I'm using a VM with the following configuration:
- Arch Linux (3.0-ARCH kernel)
- GHC 7.0.3
- cabal-install 0.10.2
- Cabal library 1.10.1.0
When I try to build zlib using cabal...
$ cabal install zlib
I get the following output:
Resolving dependencies...
Downloading zlib-0.5.3.2...
Configuring zlib-0.5.3.2...
Preprocessing library zlib-0.5.3.2...
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc: In function ‘main’:
Stream.hsc:86:21: error: missing binary operator before token "("
Stream.hsc:86:21: error: missing binary operator before token "("
compiling dist/build/Codec/Compression/Zlib/Stream_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c dist/build/Codec/Compression/Zlib/Stream_hsc_make.c -o dist/build/Codec/Compression/Zlib/Stream_hsc_make.o -fno-stack-protector -fno-stack-protector -D__GLASGOW_HASKELL__=700 -Dlinux_BUILD_OS -Dlinux_HOST_OS -Dx86_64_BUILD_ARCH -Dx86_64_HOST_ARCH -I/usr/lib/ghc-7.0.3/bytestring-0.9.1.10/include -I/usr/lib/ghc-7.0.3/base-4.3.1.0/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include -I/usr/lib/ghc-7.0.3/include/
cabal: Error: some packages failed to install:
zlib-0.5.3.2 failed during the building phase. The exception was:
ExitFailure 1
Can anyone shed some light on this build error?
Edit: Here's a snippet from Stream.hsc with line numbers:
82 import Foreign
83 ( Word8, Ptr, nullPtr, plusPtr, peekByteOff, pokeByteOff, mallocBy tes
84 , ForeignPtr, FinalizerPtr, newForeignPtr_, addForeignPtrFinalizer
85 , withForeignPtr, touchForeignPtr )
86 #if MIN_VERSION_base(4,4,0)
87 import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )
88 import System.IO.Unsafe ( unsafePerformIO )
89 #else
90 import Foreign ( unsafeForeignPtrToPtr, unsafePerformIO )
91 #endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 Ubuntu 上,我修复了(或者实际上避免了)一个类似的错误
(我不知道是否两者都需要。)
On Ubuntu, I fixed (or really, avoided) a similar error with
(I don't know if both are needed.)
由于某种原因,
MIN_VERSION_base
宏没有得到扩展,因此预处理器会看到它当然无法处理的条件MIN_VERSION_base(4,4,0)
。我还没有找到为什么宏没有扩展,但解决方法是Codec/Compression/Zlib/Stream.hsc
以删除有问题的内容宏(你使用的是7.0.3,所以你的基本版本是4.3.1.0,你可以用0替换宏)编辑:经过一番研究后,我发现为了隐藏这些预处理器指令(这些指令不适合
hsc2hs
处理),必须用额外的“#”来屏蔽它们。错误报告正在进行中。For some reason, the
MIN_VERSION_base
macro doesn't get expanded, thus the preprocessor sees the conditionMIN_VERSION_base(4,4,0)
which it of course cannot handle. I've not yet found out why the macro isn't expanded, but workarounds areCodec/Compression/Zlib/Stream.hsc
to remove the offending macro (you're using 7.0.3, so your base version is 4.3.1.0, you can replace the macro with 0)Edit: After poking around a bit, I found out that to hide these preprocessor directives, which aren't intended for
hsc2hs
to process, they have to be masked by an extra '#'. Bug report underway.我在 GHC 7.8.4 上的 haskell 包 zlib-0.5.4.2 中仍然遇到这个问题。我认为问题在于图书馆的位置不标准。我通过手动安装 zlib 1.2.8 然后执行以下操作解决了这个问题:
I'm still encountering this with the haskell package zlib-0.5.4.2 on GHC 7.8.4. I think the issue is a non-standard location of the library. I solved it by hand-installing zlib 1.2.8 and then doing:
最可能的原因是您的计算机上缺少 zlib C 库标头。您可以尝试使用 Arch Linux“Haskell Platform”或 haskell-zlib< /a> 包,为您解决 C 依赖关系。
The most likely reason is that the zlib C library headers are missing on your machine. You might instead try to use the Arch Linux "Haskell Platform" or haskell-zlib packages, which resolve C dependencies for you.
我不明白这个错误,但今天早些时候,当我尝试使用 GHC 7.4 安装 Agda 2.3 时,它也发生在我身上。 #agda 的 Saizan 建议我尝试一下,
这被证明是有效的。但我仍然不知道到底是什么问题。
尽管如此,当它起作用时,我想我会分享。
I don't understand this error, but it happened to me also earlier today while trying to install Agda 2.3 using GHC 7.4. Saizan from #agda suggested that I try
This proved effective. But I'm still in the dark about what's actually the problem.
Still, as it worked, I thought I'd share.