Ver*_*tro 6 c++ windows linker-errors visual-studio-2010
使用Visual Studio Express 2010,我创建了一个Windows项目,其中包含Windows Application和Empty Project选项.然后,我尝试了MSDN Windows教程中的以下代码片段:
#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;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?我可以告诉我最好的事情wWinMain,但它是直接从网站上复制的.
编译器似乎比学习编程更麻烦.在尝试了其他几个(主要是代码块)之后,我决定使用Visual C++,但是由于Visual C++似乎拥有最多的支持(或者至少是大多数用户),我认为它总比没有得到任何地方更好,因为它们都是如此不直观一个初学者.
使用"基本运行时检查"时,会添加_RTC_xxx符号; 要禁用它们,您可以继续项目属性,并将配置属性> C/C++>所有选项>基本运行时检查选项设置为"默认".但是,正如其他答案中所提到的,看起来您在C-Runtime库中存在不匹配.
看起来您正在链接的运行时库版本与您正在编译的版本不同。
请确保路径中仅安装了一个版本的 Visual Studio。
如果您有多个版本,请尝试临时重命名其他 Visual Studio 安装的根目录,看看这是否会产生任何影响。
| 归档时间: |
|
| 查看次数: |
14038 次 |
| 最近记录: |