Archived

This topic is now archived and is closed to further replies.

Yeah, yeah. Another DLL Export Issue

This topic is 5047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to export functions from my DLL but it doesn''t seem to work with any I try. Here are the specifics: -The .lib and .dll are contained in a folder way seperate of the .exe, but I don''t think this is relevant. -To use the .lib file, I go to Project->Settings then click on the Link tab, and type in the .lib''s name. -To export the function, I type the following relevant code in the .h file of the DLL: __declspec(dllexport) FWRESULT FWInitWin32(HINSTANCE hInstance,int width,int height,char* appName,int iShowCmd,HWND* hwnd,LRESULT (*WndProc)(HWND,UINT,WPARAM,LPARAM)); The header is included in the executable. (I would have condensed the function to having no parameters, but, however much I doubt it, the parameters could be part of the problem.) -The implementation of the function is as follows: #include <FWstandard.h> //...irrelevant code... InitWin32(hInstance,1024,768,TEXT("Test"),iShowCmd,hwnd,WndProc); //...irrelevant code... -The given error: (file location)\main.cpp(16) : error C2065: ''InitWin32'' : undeclared identifier I''m thinking this error is simply solved, but I''ve been staring at the same code for a few hours and I''m assuming that I''m totally missing something that might be more ovbious to new blood (you know, the stuff that''s supposed to go through your brain). Thank you, Joshua Merchant

Share this post


Link to post
Share on other sites
Okay, just finished eating, and tried that. Now I''m having a problem with the HWND parameter. After realizing that I was using a pointer in declaration but a regular variable while calling, I changed everything to HWND*. I got an error. So I changed everthing to a regular HWND variable. I get this:
...\main.cpp(16) : error C2664: ''FWInitWin32'' : cannot convert parameter 7 from ''long (struct HWND__ *,unsigned int,unsigned int,long)'' to ''long (__cdecl *)(struct HWND__ *,unsigned int,unsigned int,long)''

What''s with this?
(The pointer error was the same just with HWND* instead of HWND)

-Joshua Merchant the merchant

Share this post


Link to post
Share on other sites
Ow...
...\main.cpp(3) : error C2143: syntax error : missing '';'' before ''__stdcall''
...\main.cpp(3) : warning C4229: anachronism used : modifiers on data are ignored
...\main.cpp(3) : error C2501: ''LRESULT'' : missing storage-class or type specifiers
...\main.cpp(3) : error C2377: ''LRESULT'' : redefinition; typedef cannot be overloaded with any other symbol
c:\program files\microsoft visual studio\vc98\include\windef.h(172) : see declaration of ''LRESULT''
...\main.cpp(16) : error C2664: ''FWInitWin32'' : cannot convert parameter 7 from ''int (struct HWND__ *,unsigned int,unsigned int,long)'' to ''long (__cdecl *)(struct HWND__ *,unsign
ed int,unsigned int,long)''
None of the functions with this name in scope match the target type
...\main.cpp(20) : error C2143: syntax error : missing '';'' before ''__stdcall''
...\main.cpp(20) : warning C4229: anachronism used : modifiers on data are ignored
...\main.cpp(20) : error C2501: ''LRESULT'' : missing storage-class or type specifiers
...\main.cpp(20) : error C2086: ''LRESULT'' : redefinition

That''s what happened with this:
__cdecl LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);

Share this post


Link to post
Share on other sites
It goes before the function name and after the return type like:
LRESULT __cdecl WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);

However, it looks like it doesn''t work in this case because CALLBACK already specifies the calling convention for the function. Instead, add CALLBACK to the function pointer type your FWInitWin32() function accepts. i.e.:

FWRESULT FWInitWin32(HINSTANCE hInstance,int width,int height,char* appName,int iShowCmd,HWND* hwnd,LRESULT (CALLBACK *WndProc)(HWND,UINT,WPARAM,LPARAM));

Share this post


Link to post
Share on other sites
Thank you! Koodos to you for taking your time.

And koodos to the person who invented the word "koodos", even though I''m not completely positive on its definition...

-Joshua Merchant

Share this post


Link to post
Share on other sites
One last question, then I''ll leave you alone.
I have my .dll in a different folder than the .exe. Is there a way that my .exe can have something similar to a directory for the .dll''s folder? Right now I''m just copying the .dll each time I recompile it into the .exe''s folder, but this becomes a hassle. (Directory meaning Tools->Options->Directories tab in MSVC++ 6.0)

Share this post


Link to post
Share on other sites
As a project setting you should be able to change the working directory for debugging the executable and/or the output directory for the dll project. In the former you can get the executable to run in the directory with the dll. For the latter, you just automatically dump the dll in the same place as the exe.

Share this post


Link to post
Share on other sites