I am trying to link the WebAssembly version of FMOD with a C/C++ shared object that will be used within the GameMaker Engine to provide an extension interface for FMOD, and I am getting link errors when getting to the link step.
The errors I am getting are
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `.L.str`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `.L.str`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::gGlobal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_real.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `vtable for FMOD::ChannelReal`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `vtable for FMOD::ChannelSoftware`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `vtable for FMOD::DSPWaveTable`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `vtable for FMOD::DSPSource`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::ChannelReal::DEFAULT_MIN_FREQUENCY`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::ChannelReal::DEFAULT_MAX_FREQUENCY`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::ChannelReal::DEFAULT_MIN_FREQUENCY`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::ChannelReal::DEFAULT_MIN_FREQUENCY`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol `FMOD::ChannelReal::DEFAULT_MAX_FREQUENCY`; recompile with -fPIC
wasm-ld: error: ../../fmodstudioapi20213html5/api/core/lib/upstream/w32/fmod_reduced_wasm.a(fmod_channel_software.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `vtable for FMOD::ChannelSoftware`; recompile with -fPIC
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
FMOD version is fmodstudioapi20213html5 and I am linking with the core/lib/upstream/w32 libraries as all of the others either do not suit my needs (I need to link to C++ to created a shared object library) we are not using fastcomp or JS .
I am using Emscrpten 3.1.9 for testing and compilation, but I have gotten the same results with 3.1.33
I am aware of Issues with compiling for HTML5 using emscripten but the advice in here is quite out of date (particularly in WebAssembly / Emscripten terms where things have moved on quite a bit)
I have tried various versions of clang and wasm-ld and I cannot duplicate the results that the above ticket indicates.
It would appear that the FMOD code should be compiled with -fPIC enabled to be linked using recent versions of Emscripten. Would it be possible to get a version of the library that has been compiled with -fPIC???
Russell