Extension DLLs
markb@MERCMAIL.MHS.CompuServe.COM
Tuesday, April 23, 1996
VC++ 4.1
Win 95
P90 32M
I am in the process of sub-dividing my rather large application into DLLs
and libraries.
The problem that I am having is that some of the classes in some of the
extension DLLs are calling AfxGetApp() to retrieve a pointer to the
CMainFrame class. This is of course in the main application. So come
link time I get hundreds of unresolved externals.
So how can I pass the CMainFrame class into my extension DLL?
Any thoughts would be appreciated.
Regards
Mark Barnard
Avinash Saxena -- avi@outlooksoftware.com
Wednesday, November 20, 1996
Environment: Visual C++ 4.0, Win95
I have a class CMyClass defined in an extension DLL. In the extension =
DLL I also have functions like=20
DllExport foo(CMyClass * p);
, which link from the user DLL just fne.
However, if I define a function like
CMyClass * DllExport foo();
The USRDLL cannot resolve this external symbol. I suspect I am missing =
something in the function prototype which prevents foo from getting =
linked to the ext DLL.=20
Any help/pointers will be appreciated.
Thanks.
Dong Chen -- d_chen@ix.netcom.com
Friday, November 22, 1996
[Mini-digest: 2 responses]
>Environment: Visual C++ 4.0, Win95
>
>I have a class CMyClass defined in an extension DLL. In the extension =
>DLL I also have functions like=20
>DllExport foo(CMyClass * p);
>, which link from the user DLL just fne.
>
>However, if I define a function like
>CMyClass * DllExport foo();
>The USRDLL cannot resolve this external symbol. I suspect I am missing =
>something in the function prototype which prevents foo from getting =
>linked to the ext DLL.=20
>
>Any help/pointers will be appreciated.
>
>Thanks.
>
>
>
I seem not quite understand your question. But the DLL issue has been
discussed many time in this list. You may want to search the archive for
some relevant threads.
In order to export a MFC derived class, you have to use MFC Extension DLL
which has to be built using Shared MFC DLL. In your extension dll, you need
to add the AFX_EXT_CLASS in the class declaration such as:
class AFX_EXT_CLASS CMyExportClass : public CSomeMFCClass
{
...
}
You can also find out how AFX_EXT_CLASS is defined and do some customize
work around it.
The application or another dll that uses this extension dll must also be
built using MFC Shared DLL. This means it can not be a USRDLL.
Also, the term of USRDLL has been dumped by Microsoft since they have added
the ability to dynamically link to MFC library (shared MFC dll). So the
USRDLL has been extended to two versions of Regular DLL: Static Link version
and Shared Version.
For more information, please read Encyclopedia about MFC DLL.
--
Dong
d_chen@ix.netcom.com
-----From: Lin Sebastian Kayser
Dear Unknown,
did you read the documentation carefully? If yes you should have noticed =
that you put DllExport in the wrong place:
try=20
DllExport CMyClass* foo();
or
DllExport void foo();
Did you notice that in your first example you did not specify a return =
type of your function? That's bad style and if you had specified one you =
would have noticed that it had nothing to do with your CMyClass. The =
right notation for classes is btw
class DllExport Cfoo
There is a whole bunch about exporting functions and dlls in the online =
doc.
Regards,
Lin
Gruss,
Lin
.....................................................
. Lin.Kayser@Munich.Netsurf.de .
. http://ourworld.compuserve.com/homepages/Lin_Kayser .
. writing from Munich - Date: 23.11.96 Time: 20:49 .
.....................................................
| Вернуться в корень Архива
|