Link DLL with Visual C++ not working
-
I have the following problem: I have a dll compiled with MinGW and a header file that describes the DLL exports. I want to use this DLL in a Visual C++ projects. Since i don't have a LIB file and i don't want to use LoadLibrary function i created a DEF file. The contents of the EXPORTS section of the DEF file i toke from DUMPBIN /EXPORTS [the_dll], so it should be ok. After i created the lib file i included it in my Visual C++ project and the project has compiled successfully. But when i executed it, the application crashed. This application is working when compiled with GCC and the same DLL. So is the problem somewhere in MinGW or what? May be i must pass some special parameters to cl.exe or link.exe Experts please help!
-
I have the following problem: I have a dll compiled with MinGW and a header file that describes the DLL exports. I want to use this DLL in a Visual C++ projects. Since i don't have a LIB file and i don't want to use LoadLibrary function i created a DEF file. The contents of the EXPORTS section of the DEF file i toke from DUMPBIN /EXPORTS [the_dll], so it should be ok. After i created the lib file i included it in my Visual C++ project and the project has compiled successfully. But when i executed it, the application crashed. This application is working when compiled with GCC and the same DLL. So is the problem somewhere in MinGW or what? May be i must pass some special parameters to cl.exe or link.exe Experts please help!
This has probably nothing to do with the fact that it's a dll. Start your debugger to see where the program crashes.
Cédric Moonen Software developer
Charting control -
This has probably nothing to do with the fact that it's a dll. Start your debugger to see where the program crashes.
Cédric Moonen Software developer
Charting controlOk i will explain in more details: So in the header file i have a definition of an abstract class wich has onlu pure virtual methods. In the DLL i have only one export function which is returning a pointer to an instance of this class or more precisely some class that inherits this abstract class. The program is something like:
SomeClass* c = ImportedMethod(); c->someMethod(); **// Here the program crashes**
It looke strange i know, the problem is that i don't hava the source of the DLL neither i have any more information about it. Only those header:class SomeClass { public: virtual void someMethod() = 0; } extern "C" __declspec (dllexport) SomeClass * ImportedMethod();
-
Ok i will explain in more details: So in the header file i have a definition of an abstract class wich has onlu pure virtual methods. In the DLL i have only one export function which is returning a pointer to an instance of this class or more precisely some class that inherits this abstract class. The program is something like:
SomeClass* c = ImportedMethod(); c->someMethod(); **// Here the program crashes**
It looke strange i know, the problem is that i don't hava the source of the DLL neither i have any more information about it. Only those header:class SomeClass { public: virtual void someMethod() = 0; } extern "C" __declspec (dllexport) SomeClass * ImportedMethod();
What is the value of c ? Does it point to a valid memory address ? Otherwise your method could simply return NULL and you didn't check it.
Cédric Moonen Software developer
Charting control -
What is the value of c ? Does it point to a valid memory address ? Otherwise your method could simply return NULL and you didn't check it.
Cédric Moonen Software developer
Charting controlc isn't null. c contains a valid memory address and according to the Visual Studio debugger it contains the addresses of virtual functions. The same source is working when compiled with GCC. The difference may be is in the calling conventions or i don't know. But there is no problem in the source. The problem is in the dll that is used i think.