|
-
May 15th, 2002, 06:48 PM
#1
Thread Starter
Fanatic Member
DLL Problem Again!!! :(
I have been learning all the ways which you can create a DLL with VC++. The last time I learned how to do a DLL MFC. And when I tried to use it would send me an error. Somebody told me I had to copy the DLL to my debug folder of the VC++ test program. And it did work.
Now I have created a NORMAL dll. Which is quite different. Well... I am done with it. I created it with 0 error or wanrnings. I have my test VC++ program to use it. I added the lib file and also added the .h of the main dll class. I put it in the debug folder of the test program. Well... it tells me it doesnt recoginze the functions, the functions from the dll.
C:\Archivos de programa\Microsoft Visual Studio\MyProjects\p2\p2Doc.cpp(58) : error C2065: 'ModArtNewDrawing' : undeclared identifier
What in the world can it be wrong?
"The difference between mad and genius is the success"
-
May 15th, 2002, 07:13 PM
#2
Fanatic Member
Are you including the .h file (the file with the function prototypes) in your main program?
Alcohol & calculus don't mix.
Never drink & derive.
-
May 15th, 2002, 07:22 PM
#3
Thread Starter
Fanatic Member
Yes I am!
"The difference between mad and genius is the success"
-
May 15th, 2002, 09:50 PM
#4
PowerPoster
sounds like you could be having a problem with name mangling
-
May 16th, 2002, 08:05 AM
#5
Are you exporting your functions from the DLL? For instance, do your function definitions look like this:
Code:
_API void myFunc();
or
__declspec(dllexport) void myFunc();
? If not, that could be your problem.
Are you using LoadLibrary()? If that is the case, you need a .def file. Lets say that you have a function, void X(). When compiling, this will become mangled, and GetProcAddress() wont find the function. You need to create a .def file with the name of your project, with the following lines in it:
Code:
LIBRARY MyLib
EXPORTS
X
Assume that your DLL will be called MyLib. The EXPORTS line says to export the following functions from the Library, as the Name specified. So, our X function will export as X, and not as it's mangled form. When using GetProcAddress, you then just specify X as the function to find.
Z.
-
May 16th, 2002, 02:04 PM
#6
Thread Starter
Fanatic Member
this is an example of one of the dll functiona that i am exporting:
Code:
extern "C" void PASCAL EXPORT ModArtNewDrawing(CRect pRect, CObArray *poaLines)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
int lNumLines;
int lCurLine;
srand((unsigned)time(NULL));
lNumLines=rand()%50;
if (lNumLines>0)
{
for (lCurLine=0;lCurLine<lNumLines;lCurLine++)
{
NewLine(pRect, poaLines);
}
}
}
Then in the .def file I have this :
Code:
; DllNorm.def : Declares the module parameters for the DLL.
LIBRARY "DllNorm"
DESCRIPTION 'DllNorm Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
ModArtNewDrawing
ModArtSerialize
ModArtDraw
ModArtClearDrawing
What do you think is wrong?
"The difference between mad and genius is the success"
-
May 17th, 2002, 08:20 AM
#7
Originally posted by Andreex
this is an example of one of the dll functiona that i am exporting:
Code:
extern "C" void PASCAL EXPORT ModArtNewDrawing(CRect pRect, CObArray *poaLines)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
int lNumLines;
int lCurLine;
srand((unsigned)time(NULL));
lNumLines=rand()%50;
if (lNumLines>0)
{
for (lCurLine=0;lCurLine<lNumLines;lCurLine++)
{
NewLine(pRect, poaLines);
}
}
}
Then in the .def file I have this :
Code:
; DllNorm.def : Declares the module parameters for the DLL.
LIBRARY "DllNorm"
DESCRIPTION 'DllNorm Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
ModArtNewDrawing
ModArtSerialize
ModArtDraw
ModArtClearDrawing
What do you think is wrong?
Change this:
Code:
extern "C" void PASCAL EXPORT ModArtNewDrawing(CRect pRect, CObArray *poaLines)
to this:
Code:
__declspec(dllexport) void ModArtNewDrawing(CRect pRect, CObArray *poaLines)
C++ makes DLL exporting easier. You also dont need the double quotes around your LIBRARY name.
Z.
-
May 17th, 2002, 08:36 AM
#8
Thread Starter
Fanatic Member
Oh thank you! I am going to try that in a sec. Also... may ask what is the difference betweem how I had it and the way you are recommending me? THANKS A LOT!
"The difference between mad and genius is the success"
-
May 24th, 2002, 08:32 AM
#9
EXPORT is a #define that probably becomes export, which is a keyword that is deprecated in VC++6 and replaced by __declspec(dllexport)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|