Search code examples
audiogccg++mingwopenal

compiling and linking openAL with mingw?


How do I compile the following example from gamedev using mingw?. I've installed the openAl SDK to C:\Program Files (x86)\OpenAL 1.1 SDK and I have mingw and msys installed in C:\MinGW and C:\msys.

I'm not sure how to compile this or what to link. I've looked at the docs but they don't specify anything.


Solution

  • The "download sample ZIP" link on that page gives me a 404, and the snippets in the article are not complete.

    In addition to concatenating the snippets, you will at the very least need to add #include directives for al/al.h and al/alc.h in order to compile.

    To link the program, you will need to link against the OpenAL import library which is called libOpenAL32.dll.a on my system. You may alternatively find OpenAL32.lib (the MSVC version, which still should work) or only the DLL file on your system.
    --- I have both OpenAL-Soft (in 3 different builds) and the Creatix one on my system, which makes choosing the correct import lib an endeavour (even more so as manufacturers tend to always give these similar, confusing names).

    Which leads to the solution that I am using: Link directly to the DLL. Luckily, MinGW will (other than most other compilers) do that kind of thing just fine :-)

    For example, I just add -l"z:/lib/soft_oal113-sse41.dll" to the linker's commandline to link with that particular version, and it just does that without any complaints, no import libraries needed, no confusion.