我有以下源文件(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获得建议的“修复”是没有希望的。
答案 0 :(得分:2)
你应该使用Cabal,而不是直接调用GHC,因为它简化了这些事情。但这超出了范围。 :)
此特定问题的解决方案通常是在GHC命令行上列出C库,如:
ghc --make -lSDL -lSDL_mixer sdl.hs
我不使用Windows(或与GHC动态链接),所以我不知道这个命令是否有效;这只是一个想法。