Exporting class inherited from CObject in a DLL
US Projects Group -- uspr@polarism.polaris.co.in Monday, February 17, 1997 Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 Hi everyone, I have the following doubt. I had inherited a class CMyQuery from CObject and I want to export this CMyQuery class from a DLL. I put the following syntax : class _export CMyQueryClass : public CObject { .... }; The linker gives me an error that for exporting the class CMyQuery, the base class CObject must also be exported. I don't know how to solve this. Thanx in advance. ------------------------------------------------------------------------------- Polaris Software Lab Email: uspr@polarism.polaris.co.in Madras Fax: +91 (44) 8523280 Voice: +91 (44) 8522417 x 147/148 * Madras * Noida * Riyadh * Bahrain * Dubai * Iselin * Helena * * Singapore * Sydney * ORACLE MICRO FOCUS BUSINESS ALLIANCE PARTNER (ISV) YEAR 2000 CHALLENGE PARTNER -------------------------------------------------------------------------------
R. Kevin Burton -- kburton@mail.tds.net Monday, February 17, 1997 [Mini-digest: 3 responses] US Projects Group wrote: >=20 > Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 > Hi everyone, > I have the following doubt. > I had inherited a class CMyQuery from CObject and I want to export this > CMyQuery class from a DLL. I put the following syntax : > class _export CMyQueryClass : public CObject > { > .... > }; >=20 > The linker gives me an error that for exporting the class CMyQuery, the > base class CObject must also be exported. I don't know how to solve thi= s. > Thanx in advance. >=20 I am not sure what it expands to but I use class AFX_EXT_CLASS CMyQueryClass : public CObject and it works great. This expands to AFX_CLASS_EXPORT which reduces to __declspec(dllexport). I can't tell you the difference between _export=20 and __declspec(dllexport) but AFX_EXT_CLASS works. -- Kevin Burton kburton@waun.tdsnet.com -----From: Mats Manhav-- [ From: Mats Manhav * EMC.Ver #2.5.02 ] -- I do exactly what you want to do. I don't know much about the specifier _export you are using.=20 I use=20 __declspec(dllexport)=20 and=20 __declspec(dllimport)=20 in my projects The first one when declared in the dll and the latter in the=20 application that will use the exported class To make it easy (I am lazy by nature) I use the following file: >>>>>> Start of file // dlldecl.h // this define (DLLDECL) will make the classes exported when compiled in = DLL and imported when // compiled in EXE. // any class or function that will get exported/imported should be declar= ed using this macro // E.g // class DLLDECL CExportedOrImportedClass {...} #ifdef _WINDLL #define DLLDECL __declspec(dllexport) #else #define DLLDECL __declspec(dllimport) #endif =20 >>>>>>> end of file. For your class it would be like this in a header file that you can includ= e directly both in the dll and the application #include "dlldecl.h" class DLLDECL CMyQueryClass : public CObject { .... }; Good luck, Mats -------- REPLY, Original message follows -------- > Date: Monday, 17-Feb-97 10:46 AM >=20 > From: US Projects Group \ Internet: (uspr@polarism.polaris.co= .in ) > To: MFCList \ Internet: (mfc-l@netcom.com) >=20 > Subject: Exporting class inherited from CObject in a DLL >=20 > Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 > Hi everyone, > I have the following doubt. > I had inherited a class CMyQuery from CObject and I want to export this= =20 > CMyQuery class from a DLL. I put the following syntax : > class _export CMyQueryClass : public CObject > { > .... > }; >=20 > The linker gives me an error that for exporting the class CMyQuery, the= =20 > base class CObject must also be exported. I don't know how to solve thi= s.=20 > Thanx in advance. >=20 > -----------------------------------------------------------------------= --- ----- > Polaris Software Lab Email: uspr@polarism.polaris.co= .in > Madras Fax: +91 (44) 8523280 > Voice: +91 (44) 8522417 x 147/1= 48 >=20 > * Madras * Noida * Riyadh * Bahrain * Dubai * Iselin * Helena * > * Singapore * Sydney * > =20 > ORACLE MICRO FOCUS > BUSINESS ALLIANCE PARTNER (ISV) YEAR 2000 CHALLENGE PARTNER > -----------------------------------------------------------------------= --- ----- >=20 >=20 -------- REPLY, End of original message -------- -- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Mats M=E5nhav (Mats Manhav for 7-bit people) email:manhav@connectum.skurup.se WWW: http://connectum.skurup.se/~manha= v FAX: (int) 46 (0) 414 243 05 Phone: (int) 46 (0) 414 243 05 = =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -----From: Joe Willcoxson At 10:46 AM 2/17/97 +0500, you wrote: >Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 >Hi everyone, >I have the following doubt. >I had inherited a class CMyQuery from CObject and I want to export this=20 >CMyQuery class from a DLL. I put the following syntax : >class _export CMyQueryClass : public CObject >{ >.... >}; > >The linker gives me an error that for exporting the class CMyQuery, the=20 >base class CObject must also be exported. I don't know how to solve this= .=20 >Thanx in advance. It's a painful process. When you link, create a map file so you can get the decorated names. From the decorated names you can create an EXPORTS section in your .def file that lists all the exported functions. You hav= e to specify it by a per function usage, not on a per class usage. I would also include ordinals so you have the possibility of doing bug fixes on your DLL without having to re-link with you executable or other DLLs that might be dependent. The .def file for MFC itself has an EXPORTS section = to show you what you need to do. -- Gloria in excelsius Deo Joe Willcoxson (joew@statsoft.com), Senior Software Engineer Visit us: http://www.statsoft.com, Visit me: http://users.aol.com/chinajo= e #define STD_DISCLAIMER "I speak only for myself" __cplusplus spoken here;
Shaju Mathew -- shajum@hpptc51.rose.hp.com Monday, February 17, 1997 > > Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 > Hi everyone, > I have the following doubt. > I had inherited a class CMyQuery from CObject and I want to export this > CMyQuery class from a DLL. I put the following syntax : > class _export CMyQueryClass : public CObject > { > .... > }; > > The linker gives me an error that for exporting the class CMyQuery, the > base class CObject must also be exported. I don't know how to solve this. > Thanx in advance. > > ------------------------------------------------------------------------------- > Polaris Software Lab Email: uspr@polarism.polaris.co.in > Madras Fax: +91 (44) 8523280 > Voice: +91 (44) 8522417 x 147/148 > > * Madras * Noida * Riyadh * Bahrain * Dubai * Iselin * Helena * > * Singapore * Sydney * > > ORACLE MICRO FOCUS > BUSINESS ALLIANCE PARTNER (ISV) YEAR 2000 CHALLENGE PARTNER > ------------------------------------------------------------------------------- > > > Hi 'nameless in Madras', I've a number of MFC UI components exported in a DLL, all of 'em ultimately derived from CObject and experience no such linker problems!! Why don't you try the AFX.. syntax instead of your _export?? Good luck.. -Shaju Mathew #ifdef BUILD_GLANCEDLL #define AFX_EXT_UIDLL AFX_CLASS_EXPORT #else #define AFX_EXT_UIDLL AFX_CLASS_IMPORT #endif class AFX_EXT_UIDLL CInternetPropertyPage : public CPropertyPage { DECLARE_DYNCREATE(CInternetPropertyPage) private: CBitmap m_Globe[BITMAP_STATES]; .....other crappy stuff }; -- ********************************************************************** Shaju Mathew .---. .---. Performance Technology Lab /" " \ WWW / " "\ Off:(916)785-9018 WCSO Group Research & Dev / / "" \(*|*)/ "" \ \ Hewlett-Packard Company ////// '. V .` \\\\\\Home:(916)722-4576 8000, Foothills Blvd //// / // : """ : \\ \ \\\\ Mailstop 5723 // / / /`.""" '\ \ \ \\Fax:(916)785-1264 Roseville, CA 95747 // //.".\\ \\ -----------UU---UU----------- shajum@hpptc51.rose.hp.com '//|||\\` Shaju_Mathew@hp.com **********************************************************************
Joe Willcoxson -- joew@statsoft.com Tuesday, February 18, 1997 At 08:29 PM 2/17/97 PST, you wrote: > >> >> Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 >> Hi everyone, >> I have the following doubt. >> I had inherited a class CMyQuery from CObject and I want to export this >> CMyQuery class from a DLL. I put the following syntax : >> class _export CMyQueryClass : public CObject >> { >> .... >> }; >> >> The linker gives me an error that for exporting the class CMyQuery, the >> base class CObject must also be exported. I don't know how to solve this. >> Thanx in advance. >> >> ---------------------------------------------------------------------------- --- >> Polaris Software Lab Email: uspr@polarism.polaris.co.in >> Madras Fax: +91 (44) 8523280 >> Voice: +91 (44) 8522417 x 147/148 >> >> * Madras * Noida * Riyadh * Bahrain * Dubai * Iselin * Helena * >> * Singapore * Sydney * >> >> ORACLE MICRO FOCUS >> BUSINESS ALLIANCE PARTNER (ISV) YEAR 2000 CHALLENGE PARTNER >> ---------------------------------------------------------------------------- --- >> >> >> >Hi 'nameless in Madras', > I've a number of MFC UI components exported in a DLL, all of 'em >ultimately derived from CObject and experience no such linker problems!! > > Why don't you try the AFX.. syntax instead of your _export?? >Good luck.. > -Shaju Mathew >#ifdef BUILD_GLANCEDLL >#define AFX_EXT_UIDLL AFX_CLASS_EXPORT >#else >#define AFX_EXT_UIDLL AFX_CLASS_IMPORT >#endif > > >class AFX_EXT_UIDLL CInternetPropertyPage : public CPropertyPage >{ > DECLARE_DYNCREATE(CInternetPropertyPage) >private: > CBitmap m_Globe[BITMAP_STATES]; >.....other crappy stuff >}; If you follow the advice most people gave in response on how to handle this with VC++ 1.52, you will bang your head against the wall all day. All the posted responses(except mine) gave answers for VC++ 4.x, not VC++ 1.52. VC++ 4.x makes it easy, but it is a pain with 1.52. You must create a .DEF file with the decorated names like MFC itself does. See my earlier post on how to do this. -- Gloria in excelsius Deo Joe Willcoxson (joew@statsoft.com), Senior Software Engineer Visit us: http://www.statsoft.com, Visit me: http://users.aol.com/chinajoe #define STD_DISCLAIMER "I speak only for myself" __cplusplus spoken here;
Wouter-van Bommel -- Wouter-van.Bommel@unilever.com Wednesday, February 19, 1997 [Mini-digest: 3 responses] You wrote: Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 Hi everyone, I have the following doubt. I had inherited a class CMyQuery from CObject and I want to export this CMyQuery class from a DLL. I put the following syntax : class _export CMyQueryClass : public CObject { .... }; The linker gives me an error that for exporting the class CMyQuery, the base class CObject must also be exported. I don't know how to solve this. Thanx in advance. The problem can be solved by defining every function itself as exportable e.g. class CTestClass : public CObject { private: CString Str ; public: _export CTestClass(); virtual _export ~CTestClass(); CString _export GetStr(); void _export SetStr (CString Text); } ; This compiles just fine. btw. don't forget to define _AFXDLL as preprocessor symbol. hope this solves jour problem, Wouter van Bommel -----From: "Dmitry A. Dulepov"[Mailer: "Groupware E-Mail". Version 1.03.000] >I am not sure what it expands to but I use > >class AFX_EXT_CLASS CMyQueryClass : public CObject > >and it works great. This expands to AFX_CLASS_EXPORT which reduces to >__declspec(dllexport). I can't tell you the difference between _export >and __declspec(dllexport) but AFX_EXT_CLASS works. Please, note that original message was for MSVC 1.52. That version does not support __declspec(dllexport). I have that problem too and with the same product, so I made this note and looking for solution... Dmitry A. Dulepov Samsung Electronics Co., Ltd. Russian Research Center Phone: +7 (095) 213-9207 Fax: +7 (095) 213-9196 E-mail: dima@src.samsung.ru ==================================== -----From: sivas@qwiz.com (Siva Sirgiri) Joe Willcoxson wrote: > > At 08:29 PM 2/17/97 PST, you wrote: > > > >> > >> Environment : MSVC 1.52 , MFC 2.52 , WFW 3.11 > >> Hi everyone, > >> I have the following doubt. > >> I had inherited a class CMyQuery from CObject and I want to export this > >> CMyQuery class from a DLL. I put the following syntax : > >> class _export CMyQueryClass : public CObject > >> { > >> .... > >> }; > >> > >> The linker gives me an error that for exporting the class CMyQuery, the > >> base class CObject must also be exported. I don't know how to solve this. > >> Thanx in advance. > >> > >> > ---------------------------------------------------------------------------- > --- > >> Polaris Software Lab Email: uspr@polarism.polaris.co.in > >> Madras Fax: +91 (44) 8523280 > >> Voice: +91 (44) 8522417 x 147/148 > >> > >> * Madras * Noida * Riyadh * Bahrain * Dubai * Iselin * Helena * > >> * Singapore * Sydney * > >> > >> ORACLE MICRO FOCUS > >> BUSINESS ALLIANCE PARTNER (ISV) YEAR 2000 CHALLENGE PARTNER > >> > ---------------------------------------------------------------------------- > --- > >> > >> > >> > >Hi 'nameless in Madras', > > I've a number of MFC UI components exported in a DLL, all of 'em > >ultimately derived from CObject and experience no such linker problems!! > > > > Why don't you try the AFX.. syntax instead of your _export?? > >Good luck.. > > -Shaju Mathew > >#ifdef BUILD_GLANCEDLL > >#define AFX_EXT_UIDLL AFX_CLASS_EXPORT > >#else > >#define AFX_EXT_UIDLL AFX_CLASS_IMPORT > >#endif > > > > > >class AFX_EXT_UIDLL CInternetPropertyPage : public CPropertyPage > >{ > > DECLARE_DYNCREATE(CInternetPropertyPage) > >private: > > CBitmap m_Globe[BITMAP_STATES]; > >.....other crappy stuff > >}; > > If you follow the advice most people gave in response on how to handle this > with VC++ 1.52, you will bang your head against the wall all day. All the > posted responses(except mine) gave answers for VC++ 4.x, not VC++ 1.52. > VC++ 4.x makes it easy, but it is a pain with 1.52. You must create a .DEF > file with the decorated names like MFC itself does. See my earlier post on > how to do this. > -- > Gloria in excelsius Deo > Joe Willcoxson (joew@statsoft.com), Senior Software Engineer > Visit us: http://www.statsoft.com, Visit me: http://users.aol.com/chinajoe > #define STD_DISCLAIMER "I speak only for myself" > __cplusplus spoken here; Follow Joe's procedure. Otherwise u will end up banging u'r head. Most of the solns are for vc++ 4.0. Follow the MFC sample DLLHUSK and Tech notes 11 & 33 on the VC++ 1.52 CD. It has answers for most of your questions. Siva!
Become an MFC-L member | Вернуться в корень Архива |