繁体   English   中英

在Windows for Haskell(GHC)上安装SDL

[英]Installing SDL on Windows for Haskell (GHC)

背景:

我一直在使用光泽度库进行一些简单的图表工作。 但是当需要进行更多交互时,我发现我想要一个功能更强大的库。 经过研究,我决定喜欢SDL库的功能,并想尝试为其安装Haskell绑定。 至此,我一直没有成功。

第1部分:

如何安装和配置SDL二进制文件,以便Haskell绑定可以使用它们?

第2部分:

在Hackage上众多且记录不良的SDL软件包中,哪个是当前社区中首选的绑定? 如何获得该软件包以正确安装?

第3部分:(可选)

如果SDL不适合Haskell开发,那么首选的替代方法是什么?

我将回答有关SDL2的问题(也应该对SDL1进行一些修改)。

  1. 为Windows安装pkg-config( 如何在Windows中安装pkg config?

    这个工具非常重要。 各种Cabal软件包使用它来搜索库,并包含链接和编译的说明。

  2. 下载适用于Windows / MinGW的SDL开发库: http : //libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz

    如果您已安装32位版本的Haskell平台,请解压缩文件夹i686-w64-mingw32

    对于64位版本,请提取x86_64-w64-mingw32

    您将获得以下布局:

    包括
    分享
    箱子
    LIB

  3. 使用pkg-config“注册”该库。

    将lib / pkgconfig / sdl2.pc复制到pkg-config.exe的文件夹中,或相应地修改/创建PKG_CONFIG_PATH。 检查所有设置是否正确:

    C:\\ pkg-config --list-all | grep sdl2

    sdl2 sdl2-简单DirectMedia层是一个跨平台的多媒体库,旨在通过OpenGL和2D视频帧缓冲提供对音频,键盘,鼠标,操纵杆,3D硬件的低级访问。

  4. 将bin文件夹添加到PATH环境变量中。

  5. 通过Cabal安装程序安装sdl2软件包,并告诉Cabal在哪里可以找到您的库。

    示例:cabal install sdl2 --extra-include-dirs = C:\\ lib \\ sdl2 \\ include --extra-lib-dirs = C:\\ lib \\ sdl2 \\ lib \\

为了测试我的安装,我写了一个小例子:

https://github.com/ftl2014/haskell-stuff/blob/master/sdl/

买者自负:

如果Cabal抱怨库“丢失”,则可能是确实找到了库,但该库不兼容(例如,使用32位而不是64位版本)或已损坏。 头文件也是如此。 由于某种原因,Cabal抱怨找不到SDL.h,因此我不得不使用存档的根头include文件夹中的标头(但也许我只是喝了太多的Kool-aid)。

我无法将其安装在系统上。 这是我尝试过的。 奇怪的是,我能够通过configure找到头文件,但没有找到实际的二进制文件。

让我们尝试一下。 我已经安装了新的2014 Haskell平台。

cabal install sdl

Configuring SDL-0.6.5...
setup.exe: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
Failed to install SDL-0.6.5

Haskell平台中的GHC随MinGW一起提供,因此我们可能需要安装MSYS。 MSYS页面说要安装minggw get ,说要安装

自动化的GUI安装程序助手mingw-get-setup.exe是首次安装的首选方法。 这将指导您正确安装mingw-get安装程序; 然后,您将使用它来执行进一步的软件包安装并管理安装。

使用默认选项运行安装程序会显示以下屏幕:

Mingw-get GUI

安装Haskell平台已经有了mingw,因此我们只单击列表中的最后一项,即msys-base,然后选择“标记为安装”。 然后,在左上方的“安装”菜单中,选择“应用更改”。 这询问是否可以继续,然后我们选择“应用”

此安装程序未将msys-base放在路径中,我们可以将其添加到路径中,然后尝试再次安装sdl

set PATH=C:\MinGW\msys\1.0\bin\;%PATH%
cabal install sdl

Configuring SDL-0.6.5...
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
checking for sdl-config... no
checking for sdl11-config... no
configure: error: *** SDL not found! Get SDL from www.libsdl.org.
If you already installed it, check it's in the path. If problem remains,
please send a mail to the address that appears in ./configure --version
indicating your platform, the version of configure script and the problem.
Failed to install SDL-0.6.5

我们需要下载并安装libsdl。 我转到libsdl下载页面,并下载了Win32开发库SDL-devel-1.2.15-mingw32.tar.gz 我提取了此存档( 7-zip可以提取tar存档和gzip压缩文件)。 为了方便起见,我将SDL-1.2.15目录移至c: SDL-1.2.15 根据上一个错误的建议,将其添加到路径中,然后重试

set PATH=C:\SDL-1.2.15\bin\;%PATH%
cabal install sdl

* Missing (or bad) header file: SDL/SDL.h
* Missing C library: SDL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

通过添加建议的--extra-include-dirs标志,我们可以使此错误的一部分消失,但仍会出现以下错误

cabal install sdl --extra-include-dirs=c:\SDL-1.2.15\include

* Missing C library: SDL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

使用c:\\SDL-1.2.15\\binC:\\SDL-1.2.15\\libc:\\SDL-1.2.15添加--extra-lib-dirs标志无法解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM