Using Visual Studio Express 2010 I made a Windows project with the options Windows Application and Empty Project. I then tried the following code snippet from the MSDN Windows tutorials:
#include <windows.h>
#include <shobjidl.h>
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED |
COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
IFileOpenDialog *pFileOpen;
// Create the FileOpenDialog object.
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
if (SUCCEEDED(hr))
{
// Show the Open dialog box.
hr = pFileOpen->Show(NULL);
// Get the file name from the dialog box.
if (SUCCEEDED(hr))
{
IShellItem *pItem;
hr = pFileOpen->GetResult(&pItem);
if (SUCCEEDED(hr))
{
PWSTR pszFilePath;
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
// Display the file name to the user.
if (SUCCEEDED(hr))
{
MessageBox(NULL, pszFilePath, L"File Path", MB_OK);
CoTaskMemFree(pszFilePath);
}
pItem->Release();
}
}
pFileOpen->Release();
}
CoUninitialize();
}
return 0;
}
I got the following errors:
1>------ Rebuild All started: Project: Test05, Configuration: Debug Win32 ------
1> Test05.cpp
1>Test05.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8
referenced in function _wWinMain@16
1>Test05.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in
function _wWinMain@16
1>Test05.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>Test05.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>LINK : error LNK2001: unresolved external symbol _wWinMainCRTStartup
What's going on here? Best I can tell something to do with wWinMain
, but it is copied directly from the site.
Compilers seem to be far more trouble for me than learning programming. I decided on Visual C++ after trying a few others (codeblocks mostly), but since Visual C++ seems to have the most support (or at least the majority of users) I figured it was better than never getting anywhere since they all are so unintuitive to a beginner.
The _RTC_xxx symbols are added when the 'Basic Runtime Checks' are used; to disable them, you can go on the project properties, and set the Configuration Properties>C/C++>All Options>Basic Runtime Checks option to 'Default'. Though, as mentioned in the other answers, it looks like you have a mismatch in the C-Runtime libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With