c++visual-studio-codegccg++fmod

Compiling FMOD with G++ on an x64 architecture


I've been struggling to compile my program using FMOD on VS Code. I'm quite new to compiling using something else than Visual Studio's default compiler, so linking with other file formats has been a bit problematic so far. My program needs to be compiled with GCC/G++ and uses an x64 architecture.

I've tried with no success to compile with the .lib and the .dll files (I don't think they're supposed to work but I've seen somewhere that apparently it's possible if you're under Windows ?...), which with no surprise returned a bunch of undefined references. The .so file gives me a "error adding symbols: file in wrong format" message (I used the one in the x86_64 folder). I don't have any .a file in the x64 folder of the Windows version of FMOD, using the x86 one returns undefined references as well. I tried using a freeware called Lib2A to get an x64 version, but no file was output and no error message either.

I'm not quite sure what the proper way to link is at this point, here are the flags I use:

-std=c++17 -D UNICODE -mwindows -I C:\\Program Files (x86)\\FMOD SoundSystem\\FMOD Studio API Windows\\api\\core\\inc -L ${workspaceFolder}\\libraries -g ${workspaceFolder}\\*.cpp -l winmm -l wininet -l ws2_32 -l xinput -l gdi32 -l opengl32 -l fmod -o ${fileDirname}\\myapp.exe

The -l fmod part has also been ${workspaceFolder}\\libraries\\(the file I tried to load) depending on the attempts I've made. I've tried loading the .dll file directly and indirectly by having it in .exe folder.


Solution

  • After trying various solutions, I ended up learning that using the C++ structure of FMOD is incompatible with the compiler I am using, i.e. one would need to be on a compiler such as Microsoft's one.

    The solution is simple but can take a bit of time to implement: replace all the C++ functions of FMOD with their C equivalents (e.g. use FMOD_System_Create instead of FMOD::System::create).