for some reason I do not want to use the C API with MinGW 4.9, so I had to make myself an import library for fmod (L). dll, I hope it will be useful.
test example (without error checking):[code]
#include <stdio.h>
#include “fmod.hpp”
int main()
{
FMOD::System *system = NULL;
FMOD::System_Create(&system);
unsigned int version;
system->getVersion(&version);
printf("FMOD lib version %08x founded\n", version);
system->init(512, FMOD_INIT_NORMAL, 0);
system->release();
return 0;
}
[/code]
compiles and see several “undefined reference…”. add key “-Wl, - no-demangle” for linker to see the mangled names of functions:
g++ -o main.exe main.cpp -Wl,--no-demangle
...
...undefined reference to `__ZN4FMOD6System10getVersionEPj@8'
...undefined reference to `__ZN4FMOD6System4initEijPv@16'
...undefined reference to `__ZN4FMOD6System7releaseEv@4'
...undefined reference to `_FMOD_System_Create@4'
start fixing it.[list=1][]first get the export table and ordinals of fmod.dll, it needs to use dumpbin utility from Visual Studio:
dumpbin /exports fmod.dll > fmod.exports.txt
[/1tviu5j5]
[*]look at the mangled function: __ZN4[color=#008000]FMOD[/color]6[color=#008000]System[/color]10[color=#008000]getVersion[/color]EPj@8, remember the last value getVersion
[/1tviu5j5]
[]open fmod.exports.txt and find this value, get something like
[color=#0000FF]185[/color] B8 000B8AD0 ?[color=#008000]getVersion[/color]@[color=#008000]System[/color]@[color=#008000]FMOD[/color]@@QAG?AW4FMOD_RESULT@@PAI@Z
we need only the first number
[/1tviu5j5]
[]repeat this for all “undefined reference”
[/1tviu5j5]
[]create a .def file (fmod4gcc.def, for example):
LIBRARY "fmod.dll"
EXPORTS
_ZN4FMOD6System10getVersionEPj@8 @185 NONAME
_ZN4FMOD6System4initEijPv@16 @189 NONAME
_ZN4FMOD6System7releaseEv@4 @213 NONAME
FMOD_System_Create@4 @989 NONAME
[list][]_ZN4FMOD6System10getVersionEPj@8 — this is a mangled name for GCC[/1tviu5j5]
[]@185 — ordinal founded in fmod.exports.txt[/1tviu5j5]
[]NONAME — no names, ordinal only[/1tviu5j5][/list:u:1tviu5j5]
[/1tviu5j5]
[]now can create an import library:
dlltool -d fmod4gcc.def -l libfmod4gcc.a
and add the resulting library:
g++ -o main.exe main.cpp -Wl,--no-demangle -L. -lfmod4gcc
[/*1tviu5j5][/list:o:1tviu5j5]
result:[code]
main.exe
FMOD lib version 00010400 founded
[/code]
I do not know whether it is possible to automate this process, manually it takes a lot of time
but this method works, I successfully compiled all the examples shipped with the version 1.04.00