Microsoft
Software
Hardware
Network
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(fil
ename, &dwHandle);
if (cchver == 0)
{
throw LastError();
}
pver = new char[cchver];
if (!pver)
{
throw E_OUTOFMEMORY;
}
BOOL bret = GetFileVersionInfo(filenam
e, dwHandle, cchver, pver);
if (!bret)
{
throw LastError();
}
UINT uLen;
void *pbuf;
bret = VerQueryValue(pver,_T("\\"
),&pbuf,&u
Len);
if (!bret)
{
throw LastError();
}
memcpy(pvsf,pbuf,sizeof(VS
_FIXEDFILE
INFO));
}
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
Microsoft, Access, 2007, Call sub without return
Subtotaling Group Calculated Fields
SQL Server Authentication
bypass key in msaccess
SSIS: Insert New, Update existing -- how?
Wireless Laptop cannot see printer
Tweak needed in Access VB Code
VS 2008: "The designer cannot process the code at line...."
File extentions
Finding a value in a list