2016-10-28 21 views
1

残念ながら、私はthisオープンglチュートリアルから簡単なサンプルプログラムを取得できません。nixos + haskell + opengl(前提条件)

ghc --make gfx.hs 
Could not find module ‘Graphics.UI.GLUT’ 
[..] 

は、それから私は、次のことを試してみました:

cabal install GLUT 

Warning: The package list for 'hackage.haskell.org' is 44.1 days old. 
Run 'cabal update' to get the latest list of available packages. 
Resolving dependencies... 
Configuring OpenGLRaw-3.2.2.0... 
Failed to install OpenGLRaw-3.2.2.0 
Build log (/home/m/.cabal/logs/OpenGLRaw-3.2.2.0.log): 
Configuring OpenGLRaw-3.2.2.0... 
setup-Simple-Cabal-1.22.5.0-x86_64-linux-ghc-7.10.3: Missing dependency on a 
foreign library: 
* Missing C library: GL 
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. 
cabal: Error: some packages failed to install: 
GLURaw-2.0.0.2 depends on OpenGLRaw-3.2.2.0 which failed to install. 
GLUT-2.7.0.10 depends on OpenGLRaw-3.2.2.0 which failed to install. 
OpenGL-3.0.1.0 depends on OpenGLRaw-3.2.2.0 which failed to install. 
OpenGLRaw-3.2.2.0 failed during the configure step. The exception was: 
ExitFailure 1 

欠落しているCライブラリに問題があるように見えます。私はnixOSを使用していますが、これを実行するにはどのステップを実行すればよいか誰にも分かりますか?

+1

同様の質問で私の[回答](http://stackoverflow.com/questions/41527061/nixos-haskell-opengl-problems-with-building-and-running-opengl-programs/41588628#41588628)を参照してください。 –

答えて

-1

Linux(NixはLinuxディストリビューション)では、LSBはlibGLがデスクトッププロファイルの一部であると指定します。つまり、少なくともX11クライアントライブラリがインストールされている必要があります。 libGLは少し特殊ですが、グラフィックスドライバのインストールによって上書きされることが許されています。

これは次のとおりです。GPUのグラフィックドライバをインストールします。 IntelまたはAMD GPUを使用している場合は、Mesaドライバをインストールしてください。お使いのシステムにNVidia GPUが搭載されている場合は、NVidia独自のドライバを推奨します。

+0

nixosはLSBファイルシステム階層を使用しません。それが問題の全体のポイントです。 – Turion

+0

@Turion:私はLSBファイルシステムの階層に言及していませんでしたが、LSBの要件は、**ライブラリ**がデスクトップ環境の場合は名前**で利用可能でなければなりません。http://refspecs.linuxfoundation org/LSB_5.0.0/LSB-Desktop-generic/LSB-Desktop-generic/opengllib.html - ライブラリのベース名のみが指定されていますが、ファイルシステムツリーのどこには指定されていないことに注意してください。 BTW:私はNixOS開発者と親しい関係にあり、技術的な議論を楽しんでいます(Nixについても)。 – datenwolf

-1

nixosでは、ライブラリは通常、cabalが期待するパスでは使用できません。次のことを試してみてください。

nix-shell -p mesa mesa_glu cabal install GLUT

1

あなたがnix-shellを使用する場合:

$ nix-shell -p 'haskellPackages.ghcWithPackages (p: [ p.GLUT ])' 

はあなたに私はから(このコードを試してくださいましたGLUT

を知っghcを持つシェルを与えますウィキpageあなたが言った)

import Graphics.UI.GLUT 

main :: IO() 
main = do 
    (_progName, _args) <- getArgsAndInitialize 
    _window <- createWindow "Hello World" 
    displayCallback $= display 
    mainLoop 

display :: DisplayCallback 
display = do 
    clear [ ColorBuffer ] 
    flush 

しかし、より好ましい方法はshell.nixを作成して覚えておく必要がないようにすることです。 shell.nixを使用するには、引数のないnix-shellをそれが存在するディレクトリ、またはnix-shell /path/to/shell.nixのどこかに置きます。あなたがcabalstackを使用する場合がありますが、私はそれはまた別の話になると思い大きなプロジェクトのためにmanual

{ nixpkgs ? import <nixpkgs> {} }: 
with nixpkgs; 
let 
    ghc = haskellPackages.ghcWithPackages (ps: with ps; [ 
      GLUT 
     ]); 
in 
stdenv.mkDerivation { 
    name = "my-haskell-env"; 
    buildInputs = [ ghc ]; 
    shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)"; 
} 

から採用さ

shell.nix

関連する問題