使用Haskell GD绑定构建错误

时间:2010-04-28 13:37:17

标签: haskell gd ghc

我使用cabal安装了GD软件包(http://hackage.haskell.org/package/gd-3000.4.0)。当我尝试编译使用GD的程序时,我收到错误:

[mp262554@students:~/jpp/haskell]$ ghc gd.hs
compilation IS NOT required
gd.o: In function `sV8_info':
(.text+0x1bf): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_saveJpegFile_closure'
gd.o: In function `sUY_info':
(.text+0x3be): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_drawLine_closure'
gd.o: In function `sUI_info':
(.text+0x51a): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_newImage_closure'
gd.o: In function `sUI_info':
(.text+0x6a5): undefined reference to `__stginit_gdzm3000zi4zi0_GraphicsziGD_'
gd.o: In function `sVc_srt':
(.data+0x34): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_drawLine_closure'
gd.o: In function `sVc_srt':
(.data+0x38): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_saveJpegFile_closure'
gd.o: In function `sUI_srt':
(.data+0x4c): undefined reference to `gdzm3000zi4zi0_GraphicsziGD_newImage_closure'
collect2: ld returned 1 exit status

2 个答案:

答案 0 :(得分:2)

GD包提供了用C编写的GD库的绑定。您需要将C库链接到您的程序。首先尝试GHC的--make选项:

 ghc --make gd.hs
带有--make的GHC应自动计算依赖关系并正确链接多模块程序。您还可以考虑手动使用-l-L选项。

答案 1 :(得分:0)

这样的消息可能表明文件确实需要重新编译。试试ghc -fforce-recomp