Answer the question
In order to leave comments, you need to log in
Building a Windows DLL with MinGW
I'm trying to create a simple COM application, I did everything according to the tutorial.
Programming in Netbeans using MinGW. Both the client and the server itself (dll) compile perfectly. After some trouble with __stdcall, __cdecl and .def files, we even managed to register the dll in the registry. I collected the same code in VS2008, everything also compiles, registers and even works correctly.
First, I checked the dump of exported functions using objdump - everything is ok. Then, using the gendef tool, it automatically generated a .def file for the created dll. It came out like this:
LIBRARY "libCOMdll2.dll"
EXPORTS
CLSID_Component2 DATA
DllCanUnloadNow
[email protected]
[email protected]
DllRegisterServer
DllUnregisterServer
"@"
and one of them is after the name DllMain, from where the dll starts its work. After generating a .def file with another dll made in VS, I got exactly the same result - but everything works! Answer the question
In order to leave comments, you need to log in
The client created on MinGW cannot connect to the dll.
Moreover, it connects to a dll created on VisualStudio. Tobish the client works correctly.
I just really want to figure out what the “dog is buried” in.
GNU ld has many options regarding DLLs, but we shall only focus on four (help information follows):
--add-stdcall-alias Export symbols with and without @nn
--kill-at Remove @nn from exported symbols
--out- implib Generate import library
--output-def Generate a .DEF file for the built DLL
In addition to __cdecl, it may be necessary to wrap prototypes in extern "C" { }
As far as I understand, suffixes @8
, etc. are added to functions for which the call format is specified stdcall
and indicate the stack size. It depends on the compiler actually, but both MSVC and mingw
here are the same. If such a function is supposed to be exported from the resulting DLL, an alias is additionally created without a suffix, which we actually see here:
DllCanUnloadNow = @ILT+450([email protected]0)
DllMain
- @8
and @12
correct, judging by the specification - three pointers are @12
passed, but then one goes somewhere. Does it take DllMain
exactly three parameters for you?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question