Re: problem using self built DLL



See below...
On 20 Apr 2007 11:47:16 -0700, wanwan <ericwan78@xxxxxxxxx> wrote:

I made an MFC extension DLL, but I couldn't get it working on the
client application. Can somebody please tell me what I did wrong in
the procedure:

1. I started an MFC extension DLL project called "MyDll". I added a
class called "MyClass" and added the keyword AFX_EXT_CLASS in the
class declaration in the header file.

2. I built the project and copied the files "MyDll.dll" and
"MyDll.lib" to the client project folder.

3. In the client project settings, I added the file MyDll.lib in the
linker - input section.

4. I made a MyDll.h file with the line: class AFX_EXT_CLASS MyClass;
*****
So right there, you have made a serious error. You have declared that there is a class
called MyClass, AND YOU HAVE SAID NOTHING MORE ABOUT IT! This is a "forward"
declaration, wherein you promise to say something later.
*****

5. I used #include "MyDll.h" in the cpp files where I need MyClass.

With the above steps, I expect MyClass to be defined. But when I use
the imported class it gave me the error:

error C2079: 'CClientApp::myobject' uses undefined class 'MyClass'
*****
You get this error because it IS an undefined class. You promised to say something about
it later, and never did, so there is no possible way for the compiler to know what the
class does. It does not know what size it is, what members it has, or anything other than
its name (of course, had you wanted to give a meaningful error message, you would have
shown the line that this erorr complains about. It would be obvious; it would be a
declaration of a MyClass variable, or an attempt to use any method or access any member of
the class).

Your .h file must contain the entire class declaration. If you do not want the
implementation visible, then the .h file declares the class, and your implementation will
declare a derived subclass of that class.
joe
*****
*****


Please advise.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: HOWTO set up minimal sink object in console COM client?
    ... Here is my MyObject declaration: ... my console based COM object client should be able to response to ... > object for a COM interface. ... does it mean sink object is always COM object? ...
    (microsoft.public.vc.atl)
  • Re: problem using self built DLL
    ... called MyClass, AND YOU HAVE SAID NOTHING MORE ABOUT IT! ... declaration, wherein you promise to say something later. ... MyClass has no member function or member ... I thought I would start to add them after I get the DLL ...
    (microsoft.public.vc.mfc)
  • Re: Performance better with DataSet or DataReader or ...???
    ... So in any case I wasn’t planning to leave an open connection to the ... DB from the client. ... Since dataReaders usually perform better than DS, ... public MyClass GetMyClass ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Help - Best approach using Shared Classes ?
    ... >client A could be looking at table1 and client B will be looking at table2. ... >class with a Dim myClass as New MyClass? ... >Synclock would lock the class until this has completed and at this point we ... >public shared function SetTableName ...
    (microsoft.public.dotnet.framework)
  • Re: Help - Best approach using Shared Classes ?
    ... >client A could be looking at table1 and client B will be looking at table2. ... >class with a Dim myClass as New MyClass? ... >Synclock would lock the class until this has completed and at this point we ... >public shared function SetTableName ...
    (microsoft.public.dotnet.framework.aspnet)