Problems with a dll
-
Hi! I'm trying to import a dll in Visual C++ 6. Can anybody help me? When I link to that dll from another project it doesn't work. I'm sure I'm missing something, but I don't know what... Here's how the dll is written (no errors, no warnings): ************** * whatever.h * ************** #ifdef __cplusplus extern "C"{ #endif class __declspec(dllexport) MyClass{ private: char myString[100]; int myInteger; public: MyClass(); void getMyString(char * str); int getMyInteger(void); void setMyString(char * str); void setMyInteger(int); }; __declspec(dllexport) int function(MyClass * mc); **************** * whatever.cpp * **************** Just implementation here... What can I do to import the class and the function from that dll (preferably not using a .def file)??? Please, help me, I'm going mad... :(( Thank you!!!
-
Hi! I'm trying to import a dll in Visual C++ 6. Can anybody help me? When I link to that dll from another project it doesn't work. I'm sure I'm missing something, but I don't know what... Here's how the dll is written (no errors, no warnings): ************** * whatever.h * ************** #ifdef __cplusplus extern "C"{ #endif class __declspec(dllexport) MyClass{ private: char myString[100]; int myInteger; public: MyClass(); void getMyString(char * str); int getMyInteger(void); void setMyString(char * str); void setMyInteger(int); }; __declspec(dllexport) int function(MyClass * mc); **************** * whatever.cpp * **************** Just implementation here... What can I do to import the class and the function from that dll (preferably not using a .def file)??? Please, help me, I'm going mad... :(( Thank you!!!
when importing you need to declare __declspec(dllimport) An often used method when writing dll^s is following: in the header write a statement like #ifdef __MY_DLL_PROJECT__ #define _DECSPEC_ __declspec(dllexport) #else #define _DECSPEC_ __declspec(dllimport) #endif all you need to do is define the symbol _MY_DLL_PROJECT_ in your dll project, and define your class in the header as: class _DECSPEC_ MyClass { ... }; Greetings, Davy
-
when importing you need to declare __declspec(dllimport) An often used method when writing dll^s is following: in the header write a statement like #ifdef __MY_DLL_PROJECT__ #define _DECSPEC_ __declspec(dllexport) #else #define _DECSPEC_ __declspec(dllimport) #endif all you need to do is define the symbol _MY_DLL_PROJECT_ in your dll project, and define your class in the header as: class _DECSPEC_ MyClass { ... }; Greetings, Davy