Windows 编程教程中未解析的外部符号__RTC_*
Unresolved external symbols __RTC_* in Windows programming tutorial
使用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;
}
我收到以下错误:
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++ 似乎拥有最多的支持(或至少是大多数用户),我认为这总比从不去任何地方要好,因为它们对初学者来说都是如此不直观。
使用"基本运行时检查"时会添加_RTC_xxx符号;要禁用它们,您可以转到项目属性,并将"配置属性>C/C++>所有选项>基本运行时检查"选项设置为"默认"。 但是,正如其他答案中提到的,看起来您在 C 运行时库中存在不匹配。
看起来您正在链接与编译所针对的不同运行时库版本。
请确保您只安装了一个版本的 Visual Studio 和路径。
如果您有多个版本,请尝试暂时重命名其他 Visual Studio 安装的根目录,看看这是否会导致任何影响。
我会
从此处的链接下载完整的代码示例,而不是复制和粘贴您链接到的代码片段。项目文件中可能存在未显示的重要编译器/链接器设置。该示例是一个 VS 2008 解决方案,但我能够将其升级到 2010 解决方案并生成它。但是,当我尝试在VS 2008中构建它时,它给了我"致命的链接器错误:找不到'kernel32.lib'"。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 错误 LNK2019:未解析的外部符号"外部"C"此错误是什么?
- 错误 : LNK2019: 未解析的外部符号"外部 "C"