Question : error LNK2019 unresolved external symbol

Good day,

I've got a program being developed in Visual Studio .NET 2002 using VC++ and MFC.  It includes the following method, the implementation of which is taken word for word from Microsoft's setup.exe bootstrap source code for .NET installations on machines that don't yet have the .NET framework.

HRESULT CSettings::GetFileVersion(LPTSTR filename, VS_FIXEDFILEINFO* pvsf)
{
// ==========================================================================
// GetFileVersion()
//
// Purpose: retrieves a file version info structure for the specified file
//
// ==========================================================================

    DWORD dwHandle;
    HRESULT hrReturn = S_OK;
    char* pver = NULL;

    try
    {
        DWORD cchver = GetFileVersionInfoSize(filename, &dwHandle);
        if (cchver == 0)
        {
            throw LastError();
        }
        pver = new char[cchver];

        if (!pver)
        {
            throw E_OUTOFMEMORY;
        }

       BOOL bret = GetFileVersionInfo(filename, dwHandle, cchver, pver);
        if (!bret)
        {
            throw LastError();
        }
        UINT uLen;
        void *pbuf;
        bret = VerQueryValue(pver,_T("\\"),&pbuf,&uLen);
        if (!bret)
        {
            throw LastError();
        }
        memcpy(pvsf,pbuf,sizeof(VS_FIXEDFILEINFO));
    }
    catch (HRESULT hr)
    {
        hrReturn = hr;
    }

    delete[] pver;

    return hrReturn;

}

When building the program, the API calls: GetFileVersionInfoSize, GetFileVersionInfo, and VerQueryValue generate "error LNK2019 unresolved external symbol".  The files compile fine.

The help file for the API calls says:
Requirements
  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Winver.h; include Windows.h.
  Library: Use Version.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.

"windows.h" is provided via "stdafx.h" in the file, and the declarations are found there because the files compile.
The path to "Version.lib" is in the VC++ directories for lib files (C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib).  The code works in the original code downloaded and modified in (non-MFC) VC++ in the same Visual Studio program.  I'm using the code in an MFC project to easily get the dialog box main window that creating a dialog-based MFC project provides.

Why am I getting the unresolved external symbol link error?

Thanks,

Kris

Answer : error LNK2019 unresolved external symbol

You could try adding version.lib to the Object/Library modules edit box on the Link page of the Project Settings.

Hope this helps
Martyn
Random Solutions  
 
programming4us programming4us