c - 在 Windows 上为 Haskell 构建 GD 库时出现 ld 错误

标签 c haskell mingw ld ffi

在 Windows 上通过 cabal 安装 Haskell GD 包(使用 MinGW)时,我收到以下警告:

Warning: resolving _gdImagePtrDestroyIfNotNull by linking to _gdImagePtrDestroyIfNotNull@4
Warning: resolving _gdImageCopyRotated90 by linking to _gdImageCopyRotated@36
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups

请注意,这些正是 gd-extras 中定义的函数。
然后,当实际编译使用 gd 的 Haskell 程序时,我收到以下错误:

Linking Main.exe ...
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x2211):undefined reference to 'gdImageCopyRotated90'
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x500a):undefined reference to 'gdImagePtrDestroyIfNotNull'
[...]
collect2: ld returned 1 exit status

我无法弄清楚如何解决这个问题 - 我已经花了很长时间才达到这一点,因为我在尝试让它工作时遇到了更多问题,但这似乎是最后的障碍。我尝试启用/禁用 stdcall 修复,并更改在哪个文件中定义这些函数(因为 gd-extras 似乎是一个潜在问题),但这并没有解决问题。
感谢您的帮助。

最佳答案

您需要将显式链接器标志传递给 ghc,指向该库。 Haskell GD 库会自动链接,但 dll 也不会被链接,除非你告诉 ghc。 stdcall-fixup 错误在这里是一个红色鲱鱼。

关于c - 在 Windows 上为 Haskell 构建 GD 库时出现 ld 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10965687/

相关文章:

c - 二分搜索树内的二分搜索树

c - 如何使以下双线性插值代码更高效?

haskell - (<*>) 无需包装第二个参数

c++ - 对自己的库函数的 undefined reference

c++ - CMake : Linking cURL to my project : "cannot find -lcurl"

C++ 保存/加载双(到/从文件)

c - 显示切换到现代 C 编译器如何帮助发现错误的示例?

使用递归创建打印和计数链接列表

haskell - McCarthy 91 函数的工作原理

Haskell - 为树类型创建折叠函数