我有以下源文件(sdl.hs):
module Main where
import Graphics.UI.SDL.Mixer.Music
import Graphics.UI.SDL.Mixer
import Graphics.UI.SDL
main = loadMUS "" 我尝试了以下方法:
ghc --make sdl.hs
C:\Program Files (x86)\Haskell\SDL-mixer-0.6.1\ghc-7.6.3/libHSSDL-mixer-0.6.1.a(Music.o):fake:(.text+0x10): undefined reference to `Mix_FreeMusic'
...它给了我几十个这样的错误。我已经尝试了所有我能做的(更新、全新安装和Google),但我对Haskell中的FFI以及它是如何工作的几乎一无所知。
一些额外的信息:
c:\>gcc --version
realgcc.exe (GCC) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
c:\>ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
c:\>cabal install sdl sdl-mixer
Resolving dependencies...
All the requested packages are already installed:
SDL-0.6.4
SDL-mixer-0.6.1
Use --reinstall if you want to reinstall anyway.尝试从GHCi启动任何与SDL相关的内容会产生以下结果:
Prelude> import Graphics.UI.SDL.Mixer.Music
Prelude Graphics.UI.SDL.Mixer.Music> loadMUS ""
Loading package SDL-0.6.4 ... <interactive>: Unknown PEi386 section name `.idata$4' (while processing: C:\sdl\SDL-1.2.15\lib\libSDL.dll.a)
ghc.exe: panic! (the 'impossible' happened)
(GHC version 7.6.3 for i386-unknown-mingw32):
loadArchive "C:\\sdl\\SDL-1.2.15\\lib\\libSDL.dll.a": failed
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug我发现了this,它似乎是相关的,但它已经存在了一段时间,看不到windows获得拟议的“修复”的希望。
发布于 2013-06-20 11:28:53
你应该使用Cabal,而不是直接调用GHC,因为它更多地简化了这些事情。但这超出了这里的范围。:)
此特定问题的解决方案通常是在GHC命令行中列出C库,如下所示:
ghc --make -lSDL -lSDL_mixer sdl.hs
我不使用Windows (或使用GHC的动态链接),所以我不知道这个命令是否有效;这只是一个想法。
https://stackoverflow.com/questions/17158510
复制相似问题