gpt4 book ai didi

c++ - Windows编程教程中未解析的外部符号__RTC_*

转载 作者:可可西里 更新时间:2023-11-01 13:24:12 26 4
gpt4 key购买 nike

我使用 Visual Studio Express 2010 创建了一个 Windows 项目,其中包含 Windows Application 和 Empty Project 选项。然后我尝试了 following code snippet来自 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;
}

我遇到了以下错误:

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

这是怎么回事?最好我能说出与 wWinMain 有关的事情,但它是直接从站点复制的。

编译器对我来说似乎比学编程麻烦多了。在尝试了其他几个(主要是代码块)之后,我决定使用 Visual C++,但是由于 Visual C++ 似乎得到了最多的支持(或者至少是大多数用户),我认为它总比没有得到要好,因为它们都太不直观了初学者。

最佳答案

使用'Basic Runtime Checks'时添加了_RTC_xxx符号;要禁用它们,您可以继续项目属性,并将 Configuration Properties>C/C++>All Options>Basic Runtime Checks 选项设置为“Default”。虽然,如其他答案中所述,您的 C 运行时库似乎不匹配。

关于c++ - Windows编程教程中未解析的外部符号__RTC_*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10158013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com