
September 9th, 2009, 02:40 AM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 24
Time spent in forums: 13 h 41 m 21 sec
Reputation Power: 0
|
|
A problem on Linking error with dll containing a class.
I made a DLL with Dev-C++, the DLL contains a class and I tried to use the member functions of the Class in a C++ Builder2009 program,
.......................
# include <mydll.h>
....................
Toto *pGogo;
HINSTANCE hinst=LoadLibrary("mydll.dll");
pGogo=(Toto*) GetProcAddress(hinst,"Toto");
pGogo->Print();
FreeLibrary(hinst);
..............
and the mydll.h is:
#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 */
# include <iostream>
class DLLIMPORT Toto{
public:
int x;
void Print(void);
};
#endif
but there is a linking error:
[ILINK32 Error] Error: Unresolved external '__stdcall Toto::Print()' referenced from D:\RAD STUDIO\PROJECTS\DEBUG\UNIT1TEST.OBJ
But when I make a dll without a class, and use the functions from the dll in my main program,the program can be executed.
And I do not know how to solve it.
Can any one with kindness help me?
|