Error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CString __thiscall

Hi, I am trying to use 3rd party API interface in VC++ module. Below is all that I got in the package.

 < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

CdCore.dll

CdCore.lib

CdCored.dll

CdCored.lib

CdDefs.h

CdSdk.h

 

This is my program

 

#include <cstdio>

#include <conio.h>

#include <sys\types.h>

#include <string>                                 

#include <iostream>                            

 

#include <AFXWIN.H>

#include "cdsdk.h"  // Standard CDSDK header file

 

 

using std::cout;                         

 

 

CWinApp theApp;     // Keep MFC library happy (console app)

 

/* Submit a process file, wait for completion and then */

/* display the statistic records for the prccess       */

int  main(int argc, char *argv[], char *envp[])

{

            // Make sure that MFC has a valid resource handle (console app)

            AfxSetResourceHandle(::GetModuleHandle(NULL));

 

            try

            {

                        // Connect to the node and issue the 'SELECT PROCESS' command

                        CDNode node("MYNODE", "MYUSER", "MYPASSWORD");

                        CDProcIterator it = node.SelectProc();

                        while (it.HasMore())

                        {

                                    CDProcess proc = it.GetNext();

                                    cout << proc.GetNumber();

                                    cout << ' ';

                                    cout << proc.GetName();

                                    cout << ' ';

                                    cout << proc.GetQueue();

                                    cout << '\n';

                        }

            }

            catch (const CDMsgException &e)   // Catch all C:D errors

            {

                        for (int ii=0; ii < e.GetMsgCount(); ii++)

                                    cout << e.GetMsg(ii) + "\n";

            }

 

            // Flush all output to the screen and wait ten seconds.

            cout.flush();

            Sleep(10000);

 

            return 0;

}

 

 

 

My Error message

 

 







st4 - Win32 Debug--------------------
Compiling...
monTest4.cpp
c:\monica\workingfolder\sam\montest4\cddefs.h(771) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CDData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject'
c:\monica\workingfolder\sam\montest4\cddefs.h(824) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CDReference'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject'
c:\monica\workingfolder\sam\montest4\cddefs.h(955) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CDEvent'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject'
c:\monica\workingfolder\sam\montest4\cddefs.h(992) : warning C4251: 'm_event' : class 'CEvent' needs to have dll-interface to be used by clients of class 'CDEvent'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxmt.h(121) : see declaration of 'CEvent'
c:\monica\workingfolder\sam\montest4\cddefs.h(993) : warning C4251: 'm_eventChangeWait' : class 'CEvent' needs to have dll-interface to be used by clients of class

'CDEvent'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxmt.h(121) : see declaration of 'CEvent'
c:\monica\workingfolder\sam\montest4\cdsdk.h(89) : warning C4275: non dll-interface class 'CWinThread' used as base for dll-interface class 'CDThread'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3791) : see declaration of 'CWinThread'
c:\monica\workingfolder\sam\montest4\cdsdk.h(112) : warning C4251: 'm_eventExit' : class 'CEvent' needs to have dll-interface to be used by clients of class 'CDThread'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxmt.h(121) : see declaration of 'CEvent'
c:\monica\workingfolder\sam\montest4\cdsdk.h(262) : warning C4251: 'm_strKqv' : class 'CString' needs to have dll-interface to be used by clients of class 'CDStatData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(330) : warning C4251: 'm_strDescription' : class 'CString' needs to have dll-interface to be used by clients of class

'CDMsgData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(384) : warning C4251: 'm_strIP' : class 'CString' needs to have dll-interface to be used by clients of class 'CDInitParmsData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(690) : warning C4251: 'm_strName' : class 'CString' needs to have dll-interface to be used by clients of class 'CDNodeData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(697) : warning C4251: 'm_cs' : class 'CCriticalSection' needs to have dll-interface to be used by clients of class 'CDNodeData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxmt.h(145) : see declaration of 'CCriticalSection'
c:\monica\workingfolder\sam\montest4\cdsdk.h(1050) : warning C4251: 'm_astrPathNames' : class 'CStringArray' needs to have dll-interface to be used by clients of class

'CDNetmapNodeData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxcoll.h(499) : see declaration of 'CStringArray'
c:\monica\workingfolder\sam\montest4\cdsdk.h(1460) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CDMsgException'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject'
c:\monica\workingfolder\sam\montest4\cdsdk.h(1525) : warning C4251: 'm_aMsgs' : class 'CArray<struct CDMsgException::Msg,struct CDMsgException::Msg const &>' needs to have

dll-interface to be used by clients of class 'CDMsgException'
c:\monica\workingfolder\sam\montest4\cdsdk.h(1931) : warning C4251: 'm_eventComplete' : class 'CEvent' needs to have dll-interface to be used by clients of class

'CDProcData'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxmt.h(121) : see declaration of 'CEvent'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2039) : warning C4275: non dll-interface class 'CDialog' used as base for dll-interface class 'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2051) : warning C4251: 'm_btnOK' : class 'CButton' needs to have dll-interface to be used by clients of class 'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2704) : see declaration of 'CButton'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2051) : warning C4251: 'm_btnDetails' : class 'CButton' needs to have dll-interface to be used by clients of class

'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2704) : see declaration of 'CButton'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2052) : warning C4251: 'm_wndMsg' : class 'CStatic' needs to have dll-interface to be used by clients of class 'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2676) : see declaration of 'CStatic'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2052) : warning C4251: 'm_wndIcon' : class 'CStatic' needs to have dll-interface to be used by clients of class

'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2676) : see declaration of 'CStatic'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2053) : warning C4251: 'm_edit' : class 'CRichEditCtrl' needs to have dll-interface to be used by clients of class

'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxcmn.h(1012) : see declaration of 'CRichEditCtrl'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2058) : warning C4251: 'm_sizeDlgLarge' : class 'CSize' needs to have dll-interface to be used by clients of class

'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(137) : see declaration of 'CSize'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2059) : warning C4251: 'm_sizeDlgSmall' : class 'CSize' needs to have dll-interface to be used by clients of class

'CDExceptionDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(137) : see declaration of 'CSize'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2290) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CDCommand'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2345) : warning C4251: 'm_strBaseCmd' : class 'CString' needs to have dll-interface to be used by clients of class 'CDCommand'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2346) : warning C4251: 'm_mpParmToValue' : class 'CMapStringToString' needs to have dll-interface to be used by clients of

class 'CDCommand'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxcoll.h(1386) : see declaration of 'CMapStringToString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2576) : warning C4251: 'm_strProcessText' : class 'CString' needs to have dll-interface to be used by clients of class

'CDSubmitCmd'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2577) : warning C4251: 'm_strFilename' : class 'CString' needs to have dll-interface to be used by clients of class

'CDSubmitCmd'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2578) : warning C4251: 'm_mpstrstrSymbolics' : class 'CMapStringToString' needs to have dll-interface to be used by clients of

class 'CDSubmitCmd'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxcoll.h(1386) : see declaration of 'CMapStringToString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2676) : warning C4275: non dll-interface class 'CDialog' used as base for dll-interface class 'CDLogonDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2681) : warning C4251: 'm_strNode' : class 'CString' needs to have dll-interface to be used by clients of class 'CDLogonDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2682) : warning C4251: 'm_strPassword' : class 'CString' needs to have dll-interface to be used by clients of class

'CDLogonDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2683) : warning C4251: 'm_strUser' : class 'CString' needs to have dll-interface to be used by clients of class 'CDLogonDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2685) : warning C4251: 'm_strTitle' : class 'CString' needs to have dll-interface to be used by clients of class 'CDLogonDlg'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(2903) : warning C4251: 'm_strName' : class 'CString' needs to have dll-interface to be used by clients of class 'RegValue'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3006) : warning C4251: 'lcuFile' : class 'std::basic_fstream<char,struct std::char_traits<char> >' needs to have dll-interface

to be used by clients of class 'LCUNodeProperties'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3008) : warning C4251: 'm_strNode' : class 'CString' needs to have dll-interface to be used by clients of class

'LCUNodeProperties'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3009) : warning C4251: 'm_strAddress' : class 'CString' needs to have dll-interface to be used by clients of class

'LCUNodeProperties'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3010) : warning C4251: 'm_strPort' : class 'CString' needs to have dll-interface to be used by clients of class

'LCUNodeProperties'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3011) : warning C4251: 'm_strUserID' : class 'CString' needs to have dll-interface to be used by clients of class

'LCUNodeProperties'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
c:\monica\workingfolder\sam\montest4\cdsdk.h(3012) : warning C4251: 'm_strPassword' : class 'CString' needs to have dll-interface to be used by clients of class

'LCUNodeProperties'
        c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" ( 3@YAXPAX@Z) already defined in libcpmtd.lib(delop.obj)
monTest4.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CString __thiscall CDMsgException::GetMsg(int)const "

(__imp_ GetMsg@CDMsgException@@QBE AVCString@@H@Z)
Debug/monTest4.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

monTest4.exe - 3 error(s), 42 warning(s)




Answer this question

Error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CString __thiscall

  • vga

    I have set my General->Microsoft Foundataion Classes option to "use shared dll" and also set use of runtime libary to multithreaded dll. I still get this error. Please help.

    Linking...
    monTest4.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CString __thiscall CDMsgException::GetMsg(int)const " (__imp_ GetMsg@CDMsgException@@QBE AVCString@@H@Z)
    Release/monTest4.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    monTest4.exe - 2 error(s), 0 warning(s)



  • Ozbravo

    But this error has nothing to do with the previous ones.
    Simply this function is not implemented in any of the modules!
    Did you added all lib's to the linker options

  • tphsu

    I do have cdcore.lib added to linker object/modules option.

    Thanks



  • Kerdany

    Sorry than you have to ask the creator of the lib files were you have to find
    CDMsgException::GetMsg(int)const
    if its a class that is implemented by the lib creator.

    Read the docs may be this is a function you have to implement!

  • peter gardiner

    Set the MFC usage to "Shared DLL"!

  • Error LNK2001: unresolved external symbol "__declspec(dllimport) public: class CString __thiscall