簡體   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