Sunday, July 12, 2009

Visual C++ - Using DLL Code?

How do I utilize a dll in my new Windows Form Application.





I am using Visual C++ 2005 Express Edition.





I have the following code attached to a button:





private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {


char cmdstr[80]="gui_output.txt\0";


MySEAjov::proc1(cmdstr);


}





I am getting the following errors:


c:\documents and settings\seacm.seadeo\my documents\visual studio 2005\projects\mycomp\mycomp\Fo... : error C2653: 'MySEAjov' : is not a class or namespace name


c:\documents and settings\seacm.seadeo\my documents\visual studio 2005\projects\mycomp\mycomp\Fo... : error C3861: 'proc1': identifier not found





I expect this but don't know how to resolve it. I have a DLL called mycode.dll with a namespace called MySEAjov and a procedure named proc1.











How do I clue the Forms Application in to the fact that the namespace and proc are from a DLL.








Any help would be appreciated.

Visual C++ - Using DLL Code?
Add the lib file to your project. VC will understand that you want to link with it.





Include the header file for your DLL. Depending on how you organise your source files you might have to specifiy the whole path for the header, like this -





#include "C:/code/foobar.h"





or a relative path might be easier.





The biggest problem is that you can only export functions from a DLL, not namespaces. You'd need to write a function called MySEAjov_proc1 with _declspec(dllexport) attributes.





Be careful about C++ function name decoration. There is a tool (in the VC98\Bin directory of your developer studio install) called 'dumpbin'. This allows you to look at the exports from a DLL (and many other things too).
Reply:http://answers.yahoo.com/question/index;...





You still haven't told me if you have the header file and lib import file for the dll. Do you?





You can keep repeating your question endlessly, but if you ask us to play psychics you won't get much help.





You still have to follow C++ rules, regardless of what DLL or library form you use. If you don't have the namespaces, datatypes, functions, whatever declared, usually in the header file for the DLL, you can't compile.


No comments:

Post a Comment