CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    35

    error LNK2001: unresolved external symbol

    Hi,

    After searching this forum and trying a number of different possibilities I am posting this problem...

    I Have attempted compling the code below which results in:
    ==============================================

    --------------------Configuration: Fax - Win32 Debug--------------------
    Linking...
    Creating library Debug/Fax.lib and object Debug/Fax.exp
    Fax.obj : error LNK2001: unresolved external symbol __imp__FaxStartPrintJobA@16
    Debug/Fax.dll : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Fax.dll - 2 error(s), 0 warning(s)
    ===========================================
    Any assistance appreciated.

    Thanks
    Wee!
    Code:
    // Fax.h : main header file for the FAX DLL
    //
    
    #if !defined(AFX_FAX_H__FE08ECEA_8B6B_44DA_8E3A_E2C39C72135B__INCLUDED_)
    #define AFX_FAX_H__FE08ECEA_8B6B_44DA_8E3A_E2C39C72135B__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #ifndef __AFXWIN_H__
    	#error include 'stdafx.h' before including this file for PCH
    #endif
    
    #include "resource.h"		// main symbols
    
    
    #define _FAXLIB_DLLAPI_
    #define _FAXLIB_NOAUTOLIB_
    
    // The following will ensure that we are exporting our C++ classes when 
    // building the DLL and importing the classes when build an application 
    // using this DLL.
    
    #ifdef _FAXLIB_DLLAPI_
        #define FAXLIB_DLLAPI  __declspec( dllexport )
    #else
        #define FAXLIB_DLLAPI  __declspec( dllimport )
    #endif
    
    // The following will ensure that when building an application (or another
    // DLL) using this DLL, the appropriate .LIB file will automatically be used
    // when linking.
    
    #ifndef _FAXLIB_NOAUTOLIB_
    #ifdef _DEBUG
    #pragma comment(lib, "faxlibd.lib")
    #else
    #pragma comment(lib, "faxlib.lib")
    #endif
    #endif
    
    /////////////////////////////////////////////////////////////////////////////
    // CFaxApp
    // See Fax.cpp for the implementation of this class
    //
    
    class FAXLIB_DLLAPI CFaxApp : public CWinApp
    {
    public:
    	CString FaxNumber;
    
    	CString GetFaxNumber();
    	int CFaxApp::SendFax();
    	CString SetFaxNumber(CString thisFaxNumber);
    	CFaxApp();
    
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CFaxApp)
    	//}}AFX_VIRTUAL
    
    	//{{AFX_MSG(CFaxApp)
    		// NOTE - the ClassWizard will add and remove member functions here.
    		//    DO NOT EDIT what you see in these blocks of generated code !
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    };
    
    
    /////////////////////////////////////////////////////////////////////////////
    
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
    
    #endif // !defined(AFX_FAX_H__FE08ECEA_8B6B_44DA_8E3A_E2C39C72135B__INCLUDED_)
    
    // Fax.cpp : Defines the initialization routines for the DLL.
    //
    
    #include "stdafx.h"
    #include "afxv_dll.h"
    #include "winfax.h"
    #include "Fax.h"
    #include "cstring"
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    //
    //	Note!
    //
    //		If this DLL is dynamically linked against the MFC
    //		DLLs, any functions exported from this DLL which
    //		call into MFC must have the AFX_MANAGE_STATE macro
    //		added at the very beginning of the function.
    //
    //		For example:
    //
    //		extern "C" BOOL PASCAL EXPORT ExportedFunction()
    //		{
    //			AFX_MANAGE_STATE(AfxGetStaticModuleState());
    //			// normal function body here
    //		}
    //
    //		It is very important that this macro appear in each
    //		function, prior to any calls into MFC.  This means that
    //		it must appear as the first statement within the 
    //		function, even before any object variable declarations
    //		as their constructors may generate calls into the MFC
    //		DLL.
    //
    //		Please see MFC Technical Notes 33 and 58 for additional
    //		details.
    //
    
    /////////////////////////////////////////////////////////////////////////////
    // CFaxApp
    
    BEGIN_MESSAGE_MAP(CFaxApp, CWinApp)
    	//{{AFX_MSG_MAP(CFaxApp)
    		// NOTE - the ClassWizard will add and remove mapping macros here.
    		//    DO NOT EDIT what you see in these blocks of generated code!
    	//}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    /////////////////////////////////////////////////////////////////////////////
    // CFaxApp construction
    
    CFaxApp::CFaxApp()
    {
    	// TODO: add construction code here,
    	// Place all significant initialization in InitInstance
    };
    
    
    /////////////////////////////////////////////////////////////////////////////
    // The one and only CFaxApp object
    
    CFaxApp theApp;
    
    CString CFaxApp::SetFaxNumber(CString thisFaxNumber)
    {
    	return thisFaxNumber;
    };
    
    
    int CFaxApp::SendFax()
    {
    
    	FAX_PRINT_INFO fpi;
    	fpi.RecipientNumber = GetFaxNumber();
    	fpi.SizeOfStruct=sizeof(FAX_PRINT_INFO);
    
    	DWORD nJobID;
    	FAX_CONTEXT_INFO fci;
    	fci.SizeOfStruct=sizeof(FAX_CONTEXT_INFO);
    
    	if(FaxStartPrintJob(NULL,&fpi,&nJobID,&fci))
    	TRACE("FaxStartPrintJob succeeded\n");
    	return 0;
    }
    
    CString CFaxApp::GetFaxNumber()
    {
    	return FaxNumber;
    }
    Last edited by Andreas Masur; February 3rd, 2005 at 03:50 PM. Reason: Added code tags...

  2. #2
    Join Date
    Apr 2000
    Location
    Boston
    Posts
    124

    Re: error LNK2001: unresolved external symbol

    It looks like you did not link to WinFax.lib, you only included the header WinFax.h

  3. #3
    Join Date
    Jan 2005
    Posts
    35

    Re: error LNK2001: unresolved external symbol

    Man that was quick!

  4. #4
    Join Date
    Jan 2005
    Posts
    35

    Re: error LNK2001: unresolved external symbol

    Works fine - Thanks.
    Wee!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured