From: Olivier G. <li...@sa...> - 2009-05-19 20:25:08
|
Marc Vaillant wrote: > On Mon, May 18, 2009 at 11:53:16PM +0200, Olivier Guilyardi wrote: >> Jim Marshall wrote: >>> Olivier Guilyardi wrote: [...] >>>> LIBRARY "DiracLE.dll" >>>> EXPORTS >>>> ?DiracCreate@@YAPAXJJJMP6AJPAMJPAX@Z@Z >>>> ?DiracCreate@@YAPAXJJJMP6AJPAPAMJPAX@Z@Z >>>> ?DiracDestroy@@YAXPAX@Z >>>> ?DiracGetInputBufferSizeInFrames@@YAJPAX@Z >>>> ?DiracGetProperty@@YAOJPAX@Z >>>> ?DiracProcess@@YAJPAMJPAX1@Z >>>> ?DiracProcess@@YAJPAPAMJPAX1@Z >>>> ?DiracReset@@YAX_NPAX@Z >>>> ?DiracSetProperty@@YAJJOPAX@Z >>>> ?DiracVersion@@YAPBDXZ >>>> >>>> >>> Looks like those are C++ functions, presumably the DLL was compiled with >>> the Microsoft C++ compiler. Unfortunately you can not mix C++ code from >>> different vendors since each vendor has there own 'name mangling' scheme. > > This is not exactly correct. Yes, C++ name mangling is different across > vendors, however Any vendor that supports COM is vtable ABI compatible. > Please consult http://aegisknight.org/cppinterface.html which outlines > how to create binary compatible C++ interfaces. The basic idea is for > your classes to have only virtual functions, and to have C factory > methods for creating instances of them. > >> Thanks for your answer. >> >> Do you think I could write a small C'ish wrapping library around DiracLE, >> compile it with msvc and then link this in mingw? Could I export (reimp >> friendly) C symbols from my wrapper, knowing that it will itself be linked with >> the DiracLE C++ library? > > Yes, you can do this. If you want your wrapper to be C++ then you can > also do that by following the article I reference above. Thanks for this pointer. However, in the meantime I managed to dynamically load the DLL and map the (three) functions that I need using win32's LoadLibrary() and GetProcAddress() (all of this from my mingw compiled app). For instance (shortened): #include <windows.h> typedef long (__cdecl *ProcessFunction)(float **audioOut, long numFrames, void *userData, void *dirac); HINSTANCE dll = LoadLibrary(TEXT("DiracLE.dll")); ProcessFunction diracProcess = (ProcessFunction) GetProcAddress(dll, "?DiracProcess@@YAJPAPAMJPAX1@Z"); I have some stability problems (but chances are high that this comes from my alpha-state code), and it looks like gdb's getting confused (but this could be caused by multi-threading). Note: I'm actually using QtCreator, which manages all mingw compilation by itself. But all in all, this dynamic "linking" works :) Is there any reason why I shouldn't do that? -- Olivier |