Search code examples
haskellopenglc-preprocessorcabal-install

Cabal: Failed to Install GLUtil


I'm new to Haskell but I want to try and write some OpenGL experiments in it. I've successfully installed OpenGL, GLUT and a few other packages but when I attempt to install GLUtil I get the following error:

Building GLUtil-0.9.0.1...
Failed to install GLUtil-0.9.0.1
Build log ( C:\Users\David\AppData\Roaming\cabal\logs\GLUtil-0.9.0.1.log ):
Building GLUtil-0.9.0.1...
Preprocessing library GLUtil-0.9.0.1...
hpp: Couldn't open input file: -includeC:\Users\David\AppData\Local\Temp\ghc3236_0\ghc_2.h
CallStack (from HasCallStack):

error, called at src\Hpp\CmdLine.hs:89:0: error:
    22 in hpp-0.3.0.0-61vdEFyxUJDaeEBxsHCsL:Hpp.CmdLine
`hpp' failed in phase `C pre-processor'. (Exit code: 1)
cabal: Leaving directory 'C:\Users\David\AppData\Local\Temp\cabal-tmp-6356\GLUtil-0.9.0.1'
cabal: Error: some packages failed to install:
GLUtil-0.9.0.1 failed during the building phase. The exception was:
ExitFailure 1

I tried using older versions of GLUtil and its dependencies but it always ended the same way and I eventually just cleared and reinstalled the Haskell Platform (I didn't know about sandboxing).

One thing that stands out is that -includeC:\Users\Dav... looks to me like a typo, as if there should be a space between -include and C:\... but I don't know how to change this. I couldn't find CmdLine.hs, just the interface file CmdLine.hi which yielded no results.

Does anyone have any advice on how to remedy this?


Solution

  • It appears that there should be a space between the -include and the file name.

    I created a version of GLUtil-0.9.0.1 that is already preprocessed and should work for you:

    https://github.com/erantapaa/GLUtil-0.9.0.1-no-cpp

    It assumes you are using GHC 7.10.x or later.

    The steps to remove the dependency on CPP were:

    • files JuicyTextures.hs and ShaderProgram.hs just use CPP to include Control.Applicative for older versions of GHC, so I just commented out those lines. Also remove CPP from the LANGUAGE pragma.

    • Linear.hs uses CPP to generate code. You can create the pre-processed output with:

      gcc -E - < Linear.hs > new-Linear.hs
      

    Then remove lines beginning with a hash (#) and remove CPP from the LANGUAGE pragma.

    • in GLUtil.cabal comment out/remove the lines:

      if impl(ghc >= 7.10.1)
        Build-depends:     hpp >= 0.3 && < 0.4
        GHC-Options:       -pgmPhpp -optP--cpp -optP-P
      else
        Build-tools:       cpphs
        GHC-Options:       -pgmPcpphs -optP--cpp -optP