Note that there are some explanatory texts on larger screens.

plurals
  1. POLNK2019 error when building solution. Why?
    text
    copied!<p>I'm sure this has been addressed in the past. My apologies.</p> <p>I want to understand why I'm getting error LNK2019.<br /> And what direction to take, to get this resolved.<br /></p> <pre><code>Errors are LNK2019: unresolved external symbol __imp__ReportError referenced in function _wmain unresolved external symbol __imp__Options referenced in function _wmain </code></pre> <p>This occurs when I build solution in Visual Studio 2010 and up.<br /> Contents of header file for the above methods are described like so:</p> <pre><code>LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...); LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...); </code></pre> <p>Main code:<br /> </p> <pre><code>#include "Everything.h" BOOL TraverseDirectory(LPTSTR, LPTSTR, DWORD, LPBOOL); DWORD FileType(LPWIN32_FIND_DATA); BOOL ProcessItem(LPWIN32_FIND_DATA, DWORD, LPBOOL); int _tmain(int argc, LPTSTR argv[]) { BOOL flags[MAX_OPTIONS], ok = TRUE; TCHAR searchPattern[MAX_PATH + 1], currPath[MAX_PATH_LONG+1], parentPath[MAX_PATH_LONG+1]; LPTSTR pSlash, pSearchPattern; int i, fileIndex; DWORD pathLength; fileIndex = Options(argc, argv, _T("Rl"), &amp;flags[0], &amp;flags[1], NULL); pathLength = GetCurrentDirectory(MAX_PATH_LONG, currPath); if (pathLength == 0 || pathLength &gt;= MAX_PATH_LONG) { /* pathLength &gt;= MAX_PATH_LONG (32780) should be impossible */ ReportError(_T("GetCurrentDirectory failed"), 1, TRUE); } if (argc &lt; fileIndex + 1) ok = TraverseDirectory(currPath, _T("*"), MAX_OPTIONS, flags); else for (i = fileIndex; i &lt; argc; i++) { if (_tcslen(argv[i]) &gt;= MAX_PATH) { ReportError(_T("The command line argument is longer than the maximum this program supports"), 2, FALSE); } _tcscpy(searchPattern, argv[i]); _tcscpy(parentPath, argv[i]); pSlash = _tstrrchr(parentPath, _T('\\')); if (pSlash != NULL) { *pSlash = _T('\0'); _tcscat(parentPath, _T("\\")); SetCurrentDirectory(parentPath); pSlash = _tstrrchr(searchPattern, _T('\\')); pSearchPattern = pSlash + 1; } else { _tcscpy(parentPath, _T(".\\")); pSearchPattern = searchPattern; } ok = TraverseDirectory(parentPath, pSearchPattern, MAX_OPTIONS, flags) &amp;&amp; ok; SetCurrentDirectory(currPath); } return ok ? 0 : 1; } static BOOL TraverseDirectory(LPTSTR parentPath, LPTSTR searchPattern, DWORD numFlags, LPBOOL flags) { HANDLE searchHandle; WIN32_FIND_DATA findData; BOOL recursive = flags[0]; DWORD fType, iPass, lenParentPath; TCHAR subdirectoryPath[MAX_PATH + 1]; /* Open up the directory search handle and get the first file name to satisfy the path name. Make two passes. The first processes the files and the second processes the directories. */ if ( _tcslen(searchPattern) == 0 ) { _tcscat(searchPattern, _T("*")); } /* Add a backslash, if needed, at the end of the parent path */ if (parentPath[_tcslen(parentPath)-1] != _T('\\') ) { /* Add a \ to the end of the parent path, unless there already is one */ _tcscat (parentPath, _T("\\")); } /* Open up the directory search handle and get the first file name to satisfy the path name. Make two passes. The first processes the files and the second processes the directories. */ for (iPass = 1; iPass &lt;= 2; iPass++) { searchHandle = FindFirstFile(searchPattern, &amp;findData); if (searchHandle == INVALID_HANDLE_VALUE) { ReportError(_T("Error opening Search Handle."), 0, TRUE); return FALSE; } do { fType = FileType(&amp;findData); if (iPass == 1) /* ProcessItem is "print attributes". */ ProcessItem(&amp;findData, MAX_OPTIONS, flags); lenParentPath = (DWORD)_tcslen(parentPath); /* Traverse the subdirectory on the second pass. */ if (fType == TYPE_DIR &amp;&amp; iPass == 2 &amp;&amp; recursive) { _tprintf(_T("\n%s%s:"), parentPath, findData.cFileName); SetCurrentDirectory(findData.cFileName); if (_tcslen(parentPath) + _tcslen(findData.cFileName) &gt;= MAX_PATH_LONG-1) { ReportError(_T("Path Name is too long"), 10, FALSE); } _tcscpy(subdirectoryPath, parentPath); _tcscat (subdirectoryPath, findData.cFileName); /* The parent path terminates with \ before the _tcscat call */ TraverseDirectory(subdirectoryPath, _T("*"), numFlags, flags); SetCurrentDirectory(_T("..")); /* Restore the current directory */ } /* Get the next file or directory name. */ } while (FindNextFile(searchHandle, &amp;findData)); FindClose(searchHandle); } return TRUE; } static DWORD FileType(LPWIN32_FIND_DATA pFileData) { BOOL isDir; DWORD fType; fType = TYPE_FILE; isDir =(pFileData-&gt;dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) != 0; if (isDir) if (lstrcmp(pFileData-&gt;cFileName, _T(".")) == 0 || lstrcmp(pFileData-&gt;cFileName, _T("..")) == 0) fType = TYPE_DOT; else fType = TYPE_DIR; return fType; } static BOOL ProcessItem(LPWIN32_FIND_DATA pFileData, DWORD numFlags, LPBOOL flags) { const TCHAR fileTypeChar[] = {_T(' '), _T('d')}; DWORD fType = FileType(pFileData); BOOL longList = flags[1]; SYSTEMTIME lastWrite; if (fType != TYPE_FILE &amp;&amp; fType != TYPE_DIR) return FALSE; _tprintf(_T("\n")); if (longList) { _tprintf(_T("%c"), fileTypeChar[fType - 1]); _tprintf(_T("%10d"), pFileData-&gt;nFileSizeLow); FileTimeToSystemTime(&amp;(pFileData-&gt;ftLastWriteTime), &amp;lastWrite); _tprintf(_T(" %02d/%02d/%04d %02d:%02d:%02d"), lastWrite.wMonth, lastWrite.wDay, lastWrite.wYear, lastWrite.wHour, lastWrite.wMinute, lastWrite.wSecond); } _tprintf(_T(" %s"), pFileData-&gt;cFileName); return TRUE; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload