mfc >> GetDocument( ) link error

by Jessica Weiner » Sun, 26 Mar 2006 22:31:15 GMT

I am getting the following link error when I call GetDocument( ) from within
my CView class.

LNK2019: unresolved external symbol "public: class CGUI_WhidbeyDoc *
__thiscall CGUI_WhidbeyView::GetDocument(void)const "
(?GetDocument@CGUI_WhidbeyView@@QBEPAVCGUI_WhidbeyDoc@@XZ) referenced in
function "public: virtual int __thiscall CGUI_WhidbeyView::OnCreate(struct
tagCREATESTRUCTA *)"
(?OnCreate@CGUI_WhidbeyView@@UAEHPAUtagCREATESTRUCTA@@@Z)

Any ideas why?

Thanks.
Jess




mfc >> GetDocument( ) link error

by VSP » Sun, 26 Mar 2006 23:04:49 GMT


Check GetDocument implementation is provided

Class wizard will generate two GetDocument functions.
One is inline for Release version which is defined in view header file.
#ifndef _DEBUG
GetDocument
#endif

and the other is non ininline for DEBUG, which is defined in the view cpp
file.

#ifdef _DEBUG
GetDocument
#endif

-VSP.



within





Similar Threads

1. CTestDoc* GetDocument() errors in view class

I am getting these errors in my view header:

error C2143: syntax error : missing ';' before '*'
error C2501: CTestDoc: missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers

for this statement:

CTestDoc* GetDocument();

Currently, I am using

class CTestDoc;

earlier in the file to satisfy the need.

Can I get some help on this?  Much appreciated!


2. A Linking Error in VC++.net when linking to a WinCE.net dll

3. Unresolved link error, link incremental DID NOT fix!!!!

I posted a message about including a GSM library in VC++ 6.0 on a new project and I thought I had fixed it by selecting "link incremental". Well, I found out that DID NOT FIX IT. I had commecnted out the offending line:
gsmh = gsm_create();
for other testing, and forgot to uncomment it when I made the linker change ( I blame a 13 hour day for that). However, now I am right back where I started Here is the original post. Any help greatly appreaciated.

I wrote an application in VC++ 5.0 that used an external library for GSM 6.10 encode/decode and it worked fine. I started using VC++ 6.0, built the app under it and it worked fine. Now I find myself creating a new app using GSM 6.10 in VC++ 6.0, but I have run into a problem.

I add the file gsm.lib by 
Project->Setting->link->Object/library modules for all configurations. winnmm is also declared there and all calls to it's functions work fine.

But, when I attempt to build and call gsm_create() I get the following error:
 error LNK2001: unresolved external symbol "struct gsm_state * __cdecl gsm_create(void)" (?gsm_create@@YAPAUgsm_state@@XZ)

It must be finding the gsm.lib file because if I change it's name to something like gsm.lib.t, the linker complains of no such file gsm.lib.

Why am I getting the unresolved error?

tj


4. link error lnk2003 while linking IA64 application

5. Project links just fine in VC6 but link errors in 7.1

Posted this in the MFC group.  I did not get any response over there and 
I realized this is probably a more appropiate group so I am now posting 
it here,

I wrote a DLL using VC++ 7  (unmanaged) .  I have a small application 
that uses this DLL.  The application links just fine using VC6.  But if 
I try linking the same application using VC7, I get the following link 
error:

TestLink error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: unsigned int __thiscall 
GarXface4::GxList<class GarXface4::ComPortName>::GetCount(void)" 
(__imp_?GetCount@?$GxList@VComPortName@GarXface4@@@GarXface4@@QAEIXZ) 
referenced in function "protected: virtual int __thiscall 
CTestLinkDlg::OnInitDialog(void)" (?OnInitDialog@CTestLinkDlg@@MAEHXZ)


There are other class and methods within the lib / dll that give no link 
errors.  I am exporting them and importing them all the same way.


Strange thing is that some methods of GarXface4::GxList<class 
GarXface4::ComPortName> link just fine.

for example this links:

GarXface4::GxList<class GarXface4::ComPortName> comportlst;
comportlst.Clear();


but I get a link error with:


GarXface4::GxList<class GarXface4::ComPortName> comportlst;
unsigned c = comportlst.GetCount();


Any idea what I should look for?  Why would it link under VC6 but not VC7?


BTW

GarXface4::ComPortName cpn;
cpn.GetDeviceName();


links just fine so I am pretty sure it is not GarXface4::ComPortName 
causing the problem.




namespace GarXface4
{

     class ComPortName;
     class Gps;
     class ComPortList;
     class Route;
     class UsbDeviceName;
     class UsbDeviceList;
     class Waypoint;


     template <class T>
     class GARXFACE4_API GxList
     {

         friend Gps;
         friend ComPortList;
         friend Route;
         friend UsbDeviceList;


     public:
         GxList(void)
         {

         };

         ~GxList(void)
         {

         };

         T* Add(T &obj)
         {
             T *pObj = new T;
             _Add(pObj);
             return pObj;
         }

         T* InsertAtIndex(unsigned index, T &obj)
         {
             //    if (index>=m_coll.size())
             //        throw Exception(GX_ERR_INDEX_OUT_OF_RANGE,FALSE,0);

             T *pObj = new T;

             *pObj = obj;

             m_coll.insert(m_coll.begin()+index,pObj);

             return pObj;

         }

         void RemoveAtIndex(unsigned index)
         {
             T *pObj = GetAtIndex(index);
             delete pObj;
             m_coll.erase(m_coll.begin()+index);
         }

         T* GetAtIndex(unsigned index)
         {
             //if (index>=m_coll.size())
             //    throw Exception(GX_ERR_INDEX_OUT_OF_RANGE,FALSE,0);

             T* pObj = m_coll[index];
             return pObj;

         }

         unsigned GetCount()
         {
             return (unsigned)m_coll.size();
         }

         void Clear(bool deleteObjects = true)
         {
             if (deleteObjects)
                 _DeleteObjects();

             m_coll.clear();

         }

         T* operator [](unsigned index )
         {
             return GetAtIndex(index);
         }


     protected:

         T* _Add(T *pObj)
         {
             m_coll.push_back(pObj);
             return pObj;
         }
     private:

         std::vector< T* > m_coll;

         void _DeleteObjects()
         {
             unsigned i;
             unsigned c= (unsigned)m_coll.size();
             for (i=0; i<c; i++)
             {
                 T *pObj = m_coll[i];
#if defined _DEBUG
                 char szTemp[256];
                 sprintf(szTemp,"Deleteing %s 
%d\n",pObj->GetObjectName(),i);
                 OutputDebugString(szTemp);
#endif
                 delete pObj;
             }

         }


     };

     typedef GxList<Route>* RouteListPtr;
     typedef GxList<Route>  RouteList;

     typedef GxList<Waypoint>* WaypointListPtr;
     typedef GxList<Waypoint>  WaypointList;

}



-- 
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com