Haskell 尼克松+;哈斯克尔&x2B;opengl(先决条件)

Haskell 尼克松+;哈斯克尔&x2B;opengl(先决条件),haskell,opengl,nixos,Haskell,Opengl,Nixos,不幸的是,我没有从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 availabl

不幸的是,我没有从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,有人知道我必须执行哪些步骤才能运行它吗?

在Linux上(Nix是Linux发行版),LSB指定
libGL
是桌面配置文件的一部分。这意味着至少要安装X11客户端库<代码>libGL有点特殊,允许图形驱动程序安装覆盖它


这归结起来就是:为你的GPU安装图形驱动程序。如果您使用的是Intel或AMD GPU,请安装Mesa驱动程序。如果您的系统有NVidia GPU,我建议使用专有的NVidia驱动程序。

在nixos中,库通常不在cabal期望的路径上可用。请尝试以下操作:

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
nix shell-p libGL libGLU freeglut
阴谋集团

如果要使用nix shell:

$ nix-shell -p 'haskellPackages.ghcWithPackages (p: [ p.GLUT ])'
将给您一个带有
ghc
的shell,它知道
GLUT

我已尝试使用此代码(来自您提到的wiki)



对于更大的项目,您可能希望使用
cabal
stack
,但我认为这将是另一种情况。

请参阅我关于类似问题的说明。nixos不使用LSB文件系统层次结构。这就是问题的关键所在。@Turion:我指的不是LSB文件系统层次结构,而是LSB集合的要求,如果是桌面环境,则必须按名称指定哪些库——请注意,只指定了库的基本名称,而不是它在文件系统树中的位置。顺便说一句:我和一些NixOS开发人员是亲密的朋友,喜欢与他们进行技术讨论(也包括关于Nix的讨论)。
{ 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)";
}