M. Cornwell
M. Cornwell

Reputation: 51

"* Missing (or bad) C library: OpenAL32" - from stack build for a haskell project

I have a stack project using Sound.ALUT. The project was building fine on both Windows and Mac before I added sound. (Sound.ALUT is a library layered over OpenAL.) Got thinks working on MacOS but those changes broke the Windows build. Still builds fine on MacOS.

The offending snippit from the "stack build" console log on Windows looks like this

GLUT           > [22 of 24] Compiling Graphics.UI.GLUT.Callbacks.Global
GLUT           > [23 of 24] Compiling Graphics.UI.GLUT.Callbacks
GLUT           > [24 of 24] Compiling Graphics.UI.GLUT
GLUT           > copy/register
GLUT           > Installing library in C:\sr\snapshots\87ecdd59\lib\x86_64-windows-ghc-8.10.7\GLUT-2.7.0.16-2jeyeunHWey2D1Huuhst8j
GLUT           > Registering library for GLUT-2.7.0.16..
OpenAL         > configure
OpenAL         > Configuring OpenAL-1.7.0.5...
OpenAL         > Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.7.exe: Missing dependency on a foreign
OpenAL         > library:
OpenAL         > * Missing (or bad) C library: OpenAL32
OpenAL         > This problem can usually be solved by installing the system package that
OpenAL         > provides this library (you may need the "-dev" version). If the library is
OpenAL         > already installed but in a non-standard location then you can use the flags
OpenAL         > --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
OpenAL         > library file does exist, it may contain errors that are caught by the C
OpenAL         > compiler at the preprocessing stage. In this case you can re-run configure
OpenAL         > with the verbosity flag -v3 to see the error messages.
OpenAL         >
Progress 10/21

Cleary it can't find OpenAL. I've tried:

I had similar issues getting Sound.ALUT working on the Mac build. In that case building from the sources seemed to solve the problems. I have more trouble building on Windows since the build environment is less familiar. My Windows work has mostly been centered around installing Cygwin and making it look like Unix. But this time, I'm trying to get by on what stack's mingw-w64 provides. I was pulling down things with stack exec -- pacman trying to find something that would install OpenAL as a side effect but no luck.

Some subtleties arise from the fact that stack want to install things in its own self-contained environment. It tries to keep installs localized inside the project directory and not muck around with directories elsewhere. My stack environment looks like this

C:\Users\Mark\slgjff>stack path
snapshot-doc-root: C:\sr\snapshots\aff7b821\doc
local-doc-root: C:\Users\Mark\slgjff\.stack-work\install\f5431f41\doc
local-hoogle-root: C:\Users\Mark\slgjff\.stack-work\hoogle\f5431f41
stack-root: C:\sr
project-root: C:\Users\Mark\slgjff
config-location: C:\Users\Mark\slgjff\stack.yaml
bin-path: .;C:\sr\snapshots\87ecdd59\bin;C:\sr\compiler-tools\x86_64-windows\ghc-8.10.7\bin;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\bin;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\mingw\bin;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\mingw64\bin;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\usr\bin;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\usr\local\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\Mark\AppData\Roaming\local\bin;C:\Users\Mark\AppData\Local\Microsoft\WindowsApps
programs: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows
compiler-exe: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\bin\ghc-8.10.7.exe
compiler-bin: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\bin
compiler-tools-bin: C:\sr\compiler-tools\x86_64-windows\ghc-8.10.7\bin
local-bin: C:\Users\Mark\AppData\Roaming\local\bin
extra-include-dirs: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\mingw64\include
extra-library-dirs: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\mingw64\lib, C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503\mingw64\bin
snapshot-pkg-db: C:\sr\snapshots\87ecdd59\pkgdb
local-pkg-db: C:\Users\Mark\slgjff\.stack-work\install\363b2fd8\pkgdb
global-pkg-db: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\lib\package.conf.d
ghc-package-path: C:\Users\Mark\slgjff\.stack-work\install\363b2fd8\pkgdb;C:\sr\snapshots\87ecdd59\pkgdb;C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\lib\package.conf.d
snapshot-install-root: C:\sr\snapshots\87ecdd59
local-install-root: C:\Users\Mark\slgjff\.stack-work\install\363b2fd8
dist-dir: .stack-work\dist\274b403a
local-hpc-root: C:\Users\Mark\slgjff\.stack-work\install\363b2fd8\hpc
local-bin-path: C:\Users\Mark\AppData\Roaming\local\bin
ghc-paths: C:\Users\Mark\AppData\Local\Programs\stack\x86_64-windows

I'm not sure the configure needs to be happy. I wish I could construct a checklist run through, but I don't understand enough to write that checklist. Do it need the C source for header files? Don't know. Certainly it must need the .lib and .dlls on the path somewhere. But which path exactly?

My package.yaml -- which works fine on MacOS

ghc-options:
#- -dynamic
- -static

dependencies:
- base >= 4.7 && < 5
- random
- gloss
- gloss-juicy
- ALUT

library:
  source-dirs: src

executables:
  slgjff-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - slgjff

tests:
  slgjff-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - slgjff

And my stack.yaml -- which also works fine on MacOS

resolver:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/24.yaml

packages:
- .

extra-deps:
  - gloss-1.13.2.1@sha256:273d02d30e1896932d45424dab6022a16986c0ed3eef6937776b5f40854ce51c,4075
  - JuicyPixels-3.3.6@sha256:03bd32c3a884ac8a32f49334f14695469a710945c84cef9a1e059a79ac416996,3911
  - gloss-juicy-0.2.3

And because it may be helpful, here are the includes at top of my program.

import System.Exit ( exitSuccess, exitFailure )
import System.IO ( hPutStrLn, stderr )
import Data.List
import Graphics.Gloss
import Graphics.Gloss.Interface.Pure.Game
import Graphics.Gloss.Interface.IO.Game
import Graphics.Gloss.Data.Vector
import Graphics.Gloss.Juicy
import Control.Monad( when, unless )
import Sound.ALUT as S

I got so desperate I stuck C:/Windows/System32 on the path and almost spilled my drink when the build tried to delete files from C:/Windows/System32. So, I took that out. Running out of ideas.

My sense is that out of inexperience with ghc on Windows, I must be missing something that would be really obvious to someone with more experience. Thanks in advance for any insights.

P.S. I created a stripped down version of the project and put it up on github at https://github.com/markcornwell/alut-glitch

See the README for the project for instruction on how to reproduce the error.

Upvotes: 3

Views: 337

Answers (1)

cealex
cealex

Reputation: 337

To install OpenAL-1.7.0.5 (Windows):

Install the "OpenAL 1.1 Windows Installer (zip)" from https://openal.org/downloads/ on Windows.

Extract the contents of "openal-soft-1.23.1-bin.zip" from https://www.openal-soft.org/#download.

Copy the "libOpenAL32.dll.a" library to the "mingw\lib" directory

used ghcup D:\ghcup\ghc\9.4.7\mingw\lib

To discover issues during installation, use the -v3 flag with cabal install: cabal install --flag=BuildExamples -v3 > error_file.txt

"error_file.txt" {- ... Running: "D:\ghcup\ghc\9.4.7\lib../mingw/bin\gcc.exe" ... with environment: ... D:\ghcup\ghc\9.4.7\lib../mingw/bin\gcc.exe returned ExitFailure 1 D:\ghcup\ghc\9.4.7\lib../mingw/bin\gcc.exe returned ExitFailure 1 with error

message:
 note ======> D://ghcup//ghc//9.4.7//mingw//bin/ld.exe: cannot find -lOpenAL32

...

Alternatively, use cabal install --extra-lib-dirs="...lib" (not tested...)

Upvotes: 0

Related Questions