Statically linking OpenAL Soft using mingw-w64

141 views Asked by At

I'm currently trying to build a C project using mingw-w64 and make, and although I've been able to get every other library linked just fine, OpenAL Soft has been giving me a headache. I've made multiple different attempts using different files from different sites, and although the linker successfully located the files each time, gcc would either fail to create the executable due to undefined references to functions that were called (no crash occurs if I don't call them) or crash immediately on runtime after successfully building the executable due to some missing .dll. The latter occurred once last night and I'm not sure what I did exactly to cause that nor do I think I could recreate it. I'm not using "modern cmake" (if that's the correct term) and I don't want to, so please give me an answer that uses gcc commands if possible.

Here's my makefile without any OpenAL stuff if it helps:

CC=gcc
OPTS=-Iinclude -static
LIBS=-Llib -lglfw3 -lopengl32 -lgdi32

all: proj

proj: src/*.c
    $(CC) $(OPTS) $^ -o $@ $(LIBS)

There are two examples of things I've tried that were promising at first but I couldn't get working in the end.

The first thing I tried was this site which had a download link for the "OpenAL audio library for use with opengl (mingw-w64)" which still had the OpenAL Soft GitHub repository linked despite it just saying "OpenAL", and not only was I unable to get the .a from there to work by itself, but even after noticing its dependency and going down a short tree of dependencies, the folders for gcc-libs and libwinpthread didn't contain .a files and I don't know if I can interact with any of the ones present, and it still gave me undefined function errors when I tried building with the .a files I did have. Here's the site: https://packages.msys2.org/package/mingw-w64-x86_64-libwinpthread-git?repo=mingw64

I also looked through a similar question to mine on stackoverflow, but it doesn't solve my problem. It appears to be talking about regular OpenAL, not Soft, and one comment did mention being able to use Soft with mingw-w64 successfully after somehow compiling the source, but didn't explain how. The question: How to get mingw64 to link to OpenAL on windows

0

There are 0 answers