非常特定的未解决的外部符号type_info ::`vftsable在 /nodefaultlib中使用虚拟函数时
Very Specific Unresolved External Symbol type_info::`vftable When using Virtual Functions in /NODEFAULTLIB executable
我已经使用/nodefaultlib构建了一个可执行文件,但我觉得我在winmain之前的入口点上做错了一些事情,因为每当我使用虚拟方法时,我都会收到链接器错误:
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
这是我的入口点:
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
// Standard C++ Runtime (STD CRT) __xc_a points to beginning of initializer table
#pragma data_seg(".CRT$XCA")
_PVFV __xc_a[] = { 0 };
// Standard C++ Runtime (STD CRT) __xc_z points to end of initializer table
#pragma data_seg(".CRT$XCZ")
_PVFV __xc_z[] = { 0 };
#pragma data_seg(".CRT$XIA")
_PIFV __xi_a[] = {0};
#pragma data_seg(".CRT$XIZ")
_PIFV __xi_z[] = {0};
#pragma data_seg(".CRT$XPA")
_PVFV __xp_a[] = {0};
#pragma data_seg(".CRT$XPZ")
_PVFV __xp_z[] = {0};
#pragma data_seg(".CRT$XTA")
_PVFV __xt_a[] = {0};
#pragma data_seg(".CRT$XTZ")
_PVFV __xt_z[] = {0};
#pragma data_seg()
#pragma comment(linker, "/MERGE:.CRT=.rdata")
#pragma comment(linker, "/MERGE:.rdata=.data")
// function pointer table to global deinitializer table
static _PVFV * pf_atexitlist = 0;
// Maximum entries allowed in table
static unsigned max_atexitlist_entries = 32;
// Current amount of entries in table //
static unsigned cur_atexitlist_entries = 0;
void __cdecl _initterm ( _PVFV *pfbegin, _PVFV *pfend )
{
for ( ; pfbegin < pfend; pfbegin++ )
{
if ( *pfbegin != nullptr ) (**pfbegin)();
}
}
void _cdecl Exit () {
// Go through the list, and execute all global exit routines
while (cur_atexitlist_entries--) {
// execute function
(*(--pf_atexitlist)) ();
}
}
void _cdecl InitializeConstructors()
{
_initterm(__xc_a, __xc_z);
}
int WINAPI __tmainCRTStartup(void)
{
//This is obviously lacking
InitializeConstructors();
WinMain((HINSTANCE)0x400000,0,0,0);
Exit ();
return 0;
}
我觉得__tmaincrtastup中有很明显的问题,因为我相信我已经完成了DLL而不是EXE的初始化。但是我仍然对我缺少的东西有些迷失。
找到答案,需要在编译中禁用/gr-
/gr-还为我修复了它,与默认lib链接的情况相同,请确保您在MSVC中完全清除呼叫会议字段。
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么使用 "this" 指针调用派生成员函数?
- 将对象数组的引用传递给函数
- 函数调用中参数的顺序重要吗
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用不带参数的函数访问结构元素
- 代码在main()中运行,但在函数中出现错误
- 内置函数可查看CPP中的成员变量
- 如何获取std::result_of函数的返回类型
- 如何在c++中为模板函数实例创建快捷方式
- 非常特定的未解决的外部符号type_info ::`vftsable在 /nodefaultlib中使用虚拟函数时