Import a class from .DLL
-
Hi, I'm exporting this class form a dll:
#ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ class DLLIMPORT AES { public: AES(); virtual ~AES(void); private: }; #endif /* _DLL_H_ */
and this is the programm, that uses this dll:#include #include #include "..\AES\dll.h" using namespace std; int main(int argc, char *argv[]) { // Load Libary HMODULE AESLibary = LoadLibrary("../AES/AES.dll"); if (AESLibary) printf("AES.DLL found!\r\n"); else printf("AES.DLL not found!\r\n"); AES myAES; system("PAUSE"); return 0; }
but everytime I compile this program I get these errors:[Linker error] undefined reference to `AES::AES()' [Linker error] undefined reference to `AES::~AES()'
(generating the .dll file is no problem...) can anybody tell me why? thx CND -
Hi, I'm exporting this class form a dll:
#ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ class DLLIMPORT AES { public: AES(); virtual ~AES(void); private: }; #endif /* _DLL_H_ */
and this is the programm, that uses this dll:#include #include #include "..\AES\dll.h" using namespace std; int main(int argc, char *argv[]) { // Load Libary HMODULE AESLibary = LoadLibrary("../AES/AES.dll"); if (AESLibary) printf("AES.DLL found!\r\n"); else printf("AES.DLL not found!\r\n"); AES myAES; system("PAUSE"); return 0; }
but everytime I compile this program I get these errors:[Linker error] undefined reference to `AES::AES()' [Linker error] undefined reference to `AES::~AES()'
(generating the .dll file is no problem...) can anybody tell me why? thx CNDYou can not use dynamic loading (LoadLibrary) in this manner. For this statement
AES myAES;
to work you must statically link with the .lib file that is produced with the DLL. John
-
You can not use dynamic loading (LoadLibrary) in this manner. For this statement
AES myAES;
to work you must statically link with the .lib file that is produced with the DLL. John
ok, but so I which manner can I use DLLs? Is it possible to load dynamicly a class. so to use IDEA.DLL if the user selects this DLL and AES.DLL if he selects this one. This I important for me, because, I want to add crypto algorithms step by step, like plugins...
-
ok, but so I which manner can I use DLLs? Is it possible to load dynamicly a class. so to use IDEA.DLL if the user selects this DLL and AES.DLL if he selects this one. This I important for me, because, I want to add crypto algorithms step by step, like plugins...
-
Check DelayLoad if want to do that... "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me