0
0

I recently migrated my application from Visual Studio 2008 to MingW and using the C-interface instead of the C++-interface it works great.

Now I have a bunch of input plugins (that compiles fine in VS 2008) that I need to build with MingW. Is this possible at all? I have two problems to start with:

I get an error at this line:
[code:1p0cb03u]
F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()
[/code:1p0cb03u]

saying: [quote:1p0cb03u]C:\Dev\QTCreator\FMOD_FC_plugin/src/main.cpp:62: error: expected constructor, destructor, or type conversion before ‘(‘ token[/quote:1p0cb03u]

If I remove that functions it compiles, but I get linker errors on fmod’s callback functions, open/read etc. – it can’t find some functions I’m using from another lib. However I can use those functions in my constructor or deconstructor. I.e. the methods can be used in my class but not outside in FMOD’s callback functions.

Anyone knows anything about this?

  • You must to post comments
0
0

Are you making your own DLL or doing it all inline and using the createCodec function? If the latter you wouldnt need all that F_DECLSPEC F_DLLEXPORT F_API stuff probably. I don’t really know what that error is about but with a bit more code/info we can probably work it out.

  • You must to post comments
0
0

Solved!

_FMODGetCodecDescription instead of FMODGetCodecDescription did the trick!

So this is the complete working version:
[code:1lb0ed1u]
F_DECLSPEC ( dllexport ) FMOD_CODEC_DESCRIPTION* F_API _FMODGetCodecDescription()
{
return &fccodec;
}
[/code:1lb0ed1u]

Here’s some info about why this works: http://wyw.dcweb.cn/stdcall.htm

  • You must to post comments
0
0

OK, so I linked with fmodexL to enable fmod logging and also set FMOD_Debug_SetLevel(FMOD_DEBUG_ALL);

I get a lot of logging information but no info whatsoever about loading plugins. So any idea how I could solve this? How could I found out what the problem with the dll-plugin is?

  • You must to post comments
0
0

Been scratching my head a bit more with this.

So… the line which gives compile errors with MingW:
[code:1vrrlnih]F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()[/code:1vrrlnih]

works if you substitute DLLEXPORT with ( dllexport ), which is strange, since in fmod.h the following is present:
[code:1vrrlnih]#define F_DLLEXPORT ( dllexport )[/code:1vrrlnih]

So this compiles fine:
[code:1vrrlnih]F_DECLSPEC ( dllexport ) FMOD_CODEC_DESCRIPTION* F_API FMODGetCodecDescription()
{
return &fccodec;
}[/code:1vrrlnih]

I’ve made a minimal plugin that just have the required functions and returns the codec description, but with the same error (Unsupported file…). Just returning 0 for example or removing the whole dll export gives the same error, so there MUST be something wrong with the dll export… but I’m running out of ideas here…

  • You must to post comments
0
0

Ok, so I managed to compile the plugin with the following commands:
[code:1ujfpkn4]g++ *.cpp -c -Wall -I C:\FMOD\api\inc
g++ -shared -o plugin.dll *.o -Wl,–out-implib,plugin_dll.a -L C:\FMOD\api\lib -lfmodexp[/code:1ujfpkn4]

But I still get that error [quote:1ujfpkn4]Unsupported file or audio format.[/quote:1ujfpkn4] when loading the dll in my application.

So the question is, do I compile/build incorrectly or is
[code:1ujfpkn4]__declspec(dllexport) FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription(void)[/code:1ujfpkn4]
not correct?

  • You must to post comments
0
0

OK, so this compiles anyways:
[code:2ukpx3tw]__declspec(dllexport) FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription(void)[/code:2ukpx3tw]

Still got that error when loading the plugin though, which probably has to do with me including all the .cpp-files instead of the .h-files. So, any ideas why the functions defined in the .h-files can’t be found on building?

  • You must to post comments
0
0

Just to be clear: I’m not linking FMOD statically, I’m linking it dynamically (the .lib/.dll). My application loads my plugins dynamically (.dll’s).

Anyways, I managed to build my dll if I <include> all .cpp-files instead of the .h-files. This is obviously a MINGW issue, but any help with that would be greatful. When loading that .dll I get an "Unsupported file or audio format. " error.

In the plugin-example this text states:
FMODGetCodecDescription is mandatory for every fmod plugin. This is the symbol the registerplugin function searches for.

So, do I need it or not?

  • You must to post comments
0
0

The point of F_API is it to export dll symbols when compiling FMOD for win32 as a dll, when you link FMOD statically the defines will be different and F_API will not export any symbols. For this reason it is redundant to have F_DECLSPEC F_DLLEXPORT F_API, you are effectively writing the same thing twice, use one or ther other, or just explicitly use __declspec(dllexport). Since you creating a DLL and you do want to export symbols it’s probably clearer if you just use __declspec(dllexport).

  • You must to post comments
0
0

Still want some help…

I’m in pretty deep water here, messing with DLL’s and defines…

Is
[code:30riz0m1]F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()[/code:30riz0m1]
really correct för MingW?
MingW says "Unexpected token ‘FMOD_CODEC_DESCRIPTION’

Shouldn’t it be something more like:
[code:30riz0m1]FMOD_CODEC_DESCRIPTION * F_DECLSPEC F_DLLEXPORT F_API FMODGetCodecDescription()[/code:30riz0m1]
I don’t get what F_API is though…
This seems to compile:
[code:30riz0m1]int __declspec(dllexport) myfunction()[/code:30riz0m1]

  • You must to post comments
0
0

Ok, so can anyone help out with this? This is what I use to build:
g++ $SOURCEDIR/main.cpp -c
g++ -shared -o example_dll.dll main.o -Wl,–out-implib,libexample_dll.a -L C:\FMOD\api\lib -lfmodexp

And as I wrote earlier MingW doesn’t like
[code:3j1i9sqx]F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()[/code:3j1i9sqx]
and also can’t find my classes/methods I use in FMOD’s callback functions.

  • You must to post comments
0
0

I’m making my own dll. I wasn’t aware of the createCodec function (had a quick look at the API just now). Is there anything to gain on doing it inline?

So this is the code that work in VS2008 with a bit unrelevant code removed:
[code:2iuixonk]

include <fc14audiodecoder.h>

include <string.h>

include <iostream>

include <stdio.h>

include "fmod_errors.h"

FMOD_RESULT F_CALLBACK fcopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
FMOD_RESULT F_CALLBACK fcclose(FMOD_CODEC_STATE *codec);
FMOD_RESULT F_CALLBACK fcread(FMOD_CODEC_STATE *codec, void *buffer, unsigned int size, unsigned int *read);
FMOD_RESULT F_CALLBACK fcsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype);

FMOD_CODEC_DESCRIPTION fccodec =
{
"FC plugin",// Name.
0x00010000,
0,
FMOD_TIMEUNIT_MS,
&fcopen, // Open callback.
&fcclose, // Close callback.
&fcread, // Read callback.
0, // Getlength callback.
&fcsetposition, // Setposition callback.
0, // Getposition callback.
0 // Sound create callback (don’t need it)
};

class fcplugin
{
FMOD_CODEC_STATE *_codec;

public:
    fcplugin(FMOD_CODEC_STATE *codec)
    {
        _codec = codec;
        memset(&amp;fcwaveformat, 0, sizeof(fcwaveformat));
        decoder=NULL;
    }

    ~fcplugin()
    {
        //delete some stuff
        fc14dec_delete(decoder);
        decoder = NULL;
    }
void *decoder;

FMOD_CODEC_WAVEFORMAT fcwaveformat;

};

ifdef __cplusplus

extern "C" {

endif

F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()
{
return &fccodec;
}

ifdef __cplusplus

}

endif

FMOD_RESULT F_CALLBACK fcopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo)
{
FMOD_RESULT result;

fcplugin *fc = new fcplugin(codec);

unsigned int bytesread;
signed short* myBuffer;
myBuffer = new signed short[codec-&gt;filesize];

result = codec-&gt;fileseek(codec-&gt;filehandle,0,(signed short*)myBuffer);
result = codec-&gt;fileread(codec-&gt;filehandle,(signed short*)myBuffer,codec-&gt;filesize,&amp;bytesread,0);

fc-&gt;decoder = fc14dec_new();
int ok = fc14dec_init(fc-&gt;decoder,myBuffer,codec-&gt;filesize);
delete[] myBuffer;
if(!ok)
{
    return FMOD_ERR_FORMAT;
}

fc-&gt;fcwaveformat.format       = FMOD_SOUND_FORMAT_PCM16;
fc-&gt;fcwaveformat.channels     = 2;
fc-&gt;fcwaveformat.frequency    = 44100;
fc-&gt;fcwaveformat.blockalign   = (16 &gt;&gt; 3) * fc-&gt;fcwaveformat.channels;
fc-&gt;fcwaveformat.lengthpcm    = fc14dec_duration(fc-&gt;decoder)/1000*fc-&gt;fcwaveformat.frequency;

codec-&gt;waveformat   = &amp;(fc-&gt;fcwaveformat);
codec-&gt;numsubsounds = 0;
codec-&gt;plugindata   = fc;

fc14dec_mixer_init(fc-&gt;decoder,fc-&gt;fcwaveformat.frequency,16,fc-&gt;fcwaveformat.channels,0);

return FMOD_OK;

}

FMOD_RESULT F_CALLBACK fcclose(FMOD_CODEC_STATE codec)
{
delete (fcplugin
)codec->plugindata;
return FMOD_OK;
}

FMOD_RESULT F_CALLBACK fcread(FMOD_CODEC_STATE *codec, void *buffer, unsigned int size, unsigned int *read)
{
//do stuff
*read=size;
return FMOD_OK;
}

FMOD_RESULT F_CALLBACK fcsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
{
//do stuff
return FMOD_OK;
}
[/code:2iuixonk]

So, the DLL stuff gives compiler errors and I get linker errors if I call for example fc14dec_init() in fcopen, fcclose or fcread.

  • You must to post comments
Showing 11 results
Your Answer

Please first to submit.