在Windows for Haskell(GHC)上安装SDL [英] Installing SDL on Windows for Haskell (GHC)

查看:211
本文介绍了在Windows for Haskell(GHC)上安装SDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:



我一直在使用光泽度库进行一些简单的图表工作。但是当需要进行更多交互时,我发现我想要一个功能更强大的库。经过研究,我决定喜欢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



    您将获得以下布局:


    include

    share

    bin

    lib



  3. 使用pkg-config注册库。



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


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



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



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


  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)。


Background:

I've been using the gloss library for some simple diagram work. But when it came time for something more interactive, I found I wanted a more powerful library. After doing some research, I decided that I liked the features of the SDL library and wanted to try to install the Haskell bindings for it. I have to this point been unsuccessful.

Part 1:

How do I install and configure the SDL binaries so that they can be used by the Haskell bindings?

Part 2:

Which one of the numerous and ill documented SDL packages on Hackage it the current preferred binding in the community? How do I get that package to install correctly?

Part 3: (Optional)

If SDL is not a good fit for haskell development what is the preferred alternative?

解决方案

I am going to answer your question for SDL2 (should also work for SDL1 with some modifications).

  1. Install pkg-config for Windows (How to install pkg config in windows?)

    This tool is very important. It is used by various Cabal packages to search for libraries and contains directions for linking and compiling.

  2. Download the SDL development libraries for Windows/MinGW: http://libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz

    If you have installed the 32-bit version of the Haskell platform, extract the folder i686-w64-mingw32

    For 64-bit versions extract x86_64-w64-mingw32

    You will get following layout:

    include
    share
    bin
    lib

  3. "Register" the library with pkg-config.

    Either copy lib/pkgconfig/sdl2.pc into the folder of your pkg-config.exe or modify/create the PKG_CONFIG_PATH accordingly. Check that you set up everything correctly:

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

    sdl2 sdl2 - Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.

  4. Add the bin folder to your PATH environment variable.

  5. Install the sdl2 package via the Cabal installer and tell Cabal where to find your libraries.

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

To test my installation, I have written a small example:

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

Caveat emptor:

If Cabal complains about a "missing" library, it might be the case that library was actually found but it is incompatible (e.g. using a 32-bit instead of a 64-bit version) or corrupt. The same is true for header files. For some reason, Cabal complained about not finding SDL.h, and I had to use the headers in the root include folder of the archive (but maybe I was just drinking too much Kool-aid).

这篇关于在Windows for Haskell(GHC)上安装SDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆