![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 1
Rep Power: 0
![]() |
How do Mingw .def files work
I try to use a MSCV DLL in Mingw I beleve this is a procedure using .def files.
I described what i have done below and this results in a runtime error When using a MSCV DLL in mingw i get following runtime error: The procedure entry point _ZN16DSVL_VideoSource17WaitForNextSampleEl could not be located in the dynamic link library dscl.dll As far as I understand it you should create an importlibrary who can be understood by the mingw compiler. This is a .a file and not the .lib file created by MSVC. This .a file will tell mingw how to access the MSVC dll and you will still need the original dll right? The creation of the .a file can be done like this (in DOS): dlltool -U --def dsvl.def --dllname dsvl.dll --output-lib libdsvl.a Where dsvl.dll is the original MSVC dll and dsvl.def created as follows (in DOS): pexports -o dsvl.dll > dsvl.def Now you use the dll as a normal static lib: put the option to the linker -ldsvl (make sure libdsvl.a is in the lib path and dsvl.dll in the execution path) Note dlltool comes with mingw and pexports can be found online. So whats the trouble?? Well you need to edit the intermediate dsvl.def manually so the dlltool can interprete it. The my original dsvl.def looks like this: LIBRARY DSVL.dll EXPORTS ??0DSVL_VideoSource@@QAE@XZ @1 ??1DSVL_VideoSource@@QAE@XZ @2 ??4DSVL_VideoSource@@QAEAAV0@ABV0@@Z @3 ?BuildGraphFromXMLFile@DSVL_VideoSource@@QAEJPAD@Z @4 ?BuildGraphFromXMLString@DSVL_VideoSource@@QAEJPAD@Z @5 ?CheckinMemoryBuffer@DSVL_VideoSource@@QAEJUMemoryBufferHandle@@_N@Z @6 ?CheckoutMemoryBuffer@DSVL_VideoSource@@QAEJPAUMemoryBufferHandle@@PAPAEPAI2PAW4_PIXELFORMAT@@PA_J@Z @7 ?DisableMemoryBuffer@DSVL_VideoSource@@QAEJXZ @8 ?EnableMemoryBuffer@DSVL_VideoSource@@QAEJII@Z @9 ?GetCurrentMediaFormat@DSVL_VideoSource@@QAEJPAJ0PANPAW4_PIXELFORMAT@@@Z @10 ?GetCurrentTimestamp@DSVL_VideoSource@@QAE_JXZ @11 ?IsGraphInitialized@DSVL_VideoSource@@QAE_NXZ @12 ?Pause@DSVL_VideoSource@@QAEJXZ @13 ?ReleaseGraph@DSVL_VideoSource@@QAEJXZ @14 ?Run@DSVL_VideoSource@@QAEJXZ @15 ?ShowFilterProperties@DSVL_VideoSource@@QAEJXZ @16 ?Stop@DSVL_VideoSource@@QAEJ_N@Z @17 ?WaitForNextSample@DSVL_VideoSource@@QAEKJ@Z @18 To have an idea of what the dlltool expects as a correct .def file, I did the following: I took the dll headerfile (msvc compatible) and gave it a dummy implementation, changed #ifdef DSVL_EXPORTS #define DSVL_API __declspec(dllexport) #else #define DSVL_API __declspec(dllimport) #endif To #if BUILDING_DLL #define DSVL_API __declspec(dllexport) #else #define DSVL_API __declspec(dllimport) #endif And compiled it as a mingw dll. This compilation generates automaticaly a .def file and .a as wel. This .def file looks like this: ; dlltool --base-file C:\DOCUME~1\admin\LOCALS~1\Temp/cca04076.base --output-exp mingw_dsvl.exp --dllname mingw_dsvl.dll --output-def libmingw_dsvl.def --no-export-all-symbols --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def C:\DOCUME~1\admin\LOCALS~1\Temp/cca04076.def --output-lib libmingw_dsvl.a EXPORTS ; DSVL_VideoSource::ReleaseGraph() _ZN16DSVL_VideoSource12ReleaseGraphEv @ 1 ; DSVL_VideoSource::WaitForNextSample(long) _ZN16DSVL_VideoSource17WaitForNextSampleEl @ 2 ; DSVL_VideoSource::EnableMemoryBuffer(unsigned int, unsigned int) _ZN16DSVL_VideoSource18EnableMemoryBufferEjj @ 3 ; DSVL_VideoSource::IsGraphInitialized() _ZN16DSVL_VideoSource18IsGraphInitializedEv @ 4 ; DSVL_VideoSource::CheckinMemoryBuffer(MemoryBufferHandle, bool) _ZN16DSVL_VideoSource19CheckinMemoryBufferE18MemoryBufferHandleb @ 5 ; DSVL_VideoSource: isableMemoryBuffer()_ZN16DSVL_VideoSource19DisableMemoryBufferEv @ 6 ; DSVL_VideoSource::GetCurrentTimestamp() _ZN16DSVL_VideoSource19GetCurrentTimestampEv @ 7 ; DSVL_VideoSource::CheckoutMemoryBuffer(MemoryBufferHandle*, unsigned char**, unsigned int*, unsigned int*, _PIXELFORMAT*, long long*) _ZN16DSVL_VideoSource20CheckoutMemoryBufferEP18MemoryBufferHandlePPhPjS4_P12_PIXELFORMATPx @ 8 ; DSVL_VideoSource: howFilterProperties()_ZN16DSVL_VideoSource20ShowFilterPropertiesEv @ 9 ; DSVL_VideoSource::BuildGraphFromXMLFile(char*) _ZN16DSVL_VideoSource21BuildGraphFromXMLFileEPc @ 10 ; DSVL_VideoSource::GetCurrentMediaFormat(long*, long*, double*, _PIXELFORMAT*) _ZN16DSVL_VideoSource21GetCurrentMediaFormatEPlS0_PdP12_PIXELFORMAT @ 11 ; DSVL_VideoSource::BuildGraphFromXMLString(char*) _ZN16DSVL_VideoSource23BuildGraphFromXMLStringEPc @ 12 ; DSVL_VideoSource::Run() _ZN16DSVL_VideoSource3RunEv @ 13 ; DSVL_VideoSource: top(bool)_ZN16DSVL_VideoSource4StopEb @ 14 ; DSVL_VideoSource: ause()_ZN16DSVL_VideoSource5PauseEv @ 15 ; DSVL_VideoSource: SVL_VideoSource()_ZN16DSVL_VideoSourceC1Ev @ 16 ; DSVL_VideoSource: SVL_VideoSource()_ZN16DSVL_VideoSourceC2Ev @ 17 ; DSVL_VideoSource::~DSVL_VideoSource() _ZN16DSVL_VideoSourceD1Ev @ 18 ; DSVL_VideoSource::~DSVL_VideoSource() _ZN16DSVL_VideoSourceD2Ev @ 19 Than i took the original dsvl.def and changed the names as follows: LIBRARY DSVL.dll EXPORTS _ZN16DSVL_VideoSourceC1Ev @1 _ZN16DSVL_VideoSourceC2Ev @2 _ZN16DSVL_VideoSourceD1Ev @3 _ZN16DSVL_VideoSource21BuildGraphFromXMLFileEPc @4 _ZN16DSVL_VideoSource23BuildGraphFromXMLStringEPc @5 ... _ZN16DSVL_VideoSource17WaitForNextSampleEl @18 (Which is probably incorrect !!!) This altered def file is then used in the dlltool and libdsvl.a is used in mingw (exe) project. This last project compiles and links well, but at the point of execution I get a runtime error pupup window saying: The procedure entry point _ZN16DSVL_VideoSource17WaitForNextSampleEl could not be located in the dynamic link library dscl.dll What am I doing wrong?? It took me 3 days now and i am thinking of changing carreer as a munik! Note the original def had only 18 entries (the mingw dll 19), the order is different and the whats up with duplicate entries for the constructor. The diference in entries is due to the mingw dll having 2 entries for the destructor vs. 1 in the msvc dll. Any ideas? Whats my next move? Mybe its usefull to check out the included files msvcDllForMingw.zip |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|