我想用MingW在windows上编写C++ Qt崩溃报告。我参考了https://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c/ ,但我的代码不能编译并给出以下错误 - 我在Qt 5.4.0 mingw的Windows 10上使用此代码。编译此代码时出现一些错误。 错误:未定义参照[email protected]′ error: undefined reference to
_imp__SymGetModuleBase @ 8' 错误:未定义参照[email protected]′ error: undefined reference to
_imp__StackWalk @ 36' 错误:未定义参考`_imp__SymCleanup @ 4'Windows上的C++ Mingw崩溃报告
这些错误是从下面的代码。
void windows_print_stacktrace(CONTEXT* context)
{
SymInitialize(GetCurrentProcess(), 0, true);
STACKFRAME frame = { 0 };
/* setup initial stack frame */
frame.AddrPC.Offset = context->Eip;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrStack.Offset = context->Esp;
frame.AddrStack.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context->Ebp;
frame.AddrFrame.Mode = AddrModeFlat;
while (StackWalk(IMAGE_FILE_MACHINE_I386 ,
GetCurrentProcess(),
GetCurrentThread(),
&frame,
context,
0,
SymFunctionTableAccess,
SymGetModuleBase,
0))
{
addr2line(icky_global_program_name, (void*)frame.AddrPC.Offset);
}
SymCleanup(GetCurrentProcess());
}
imagehlp.dll负责上述功能。 有人可以告诉我如何解决这种类型的错误。
在此先感谢。
我做到了。但仍然是相同的错误。有没有什么办法来检查它需要哪个版本的dll。因为我正在使用Windows 10 64位机器,并且系统已经在system32等许多文件夹中有很多imagehlp.dll。 – Abhi
ImageHlp经历了许多版本,并且使用其他工具进行了很多重新分发。然而,特定的DLL还没有(你)的问题,因为它无法链接导入库(.lib)。它看起来好像是在编译32位x86,但可能选择了64位DLL的导入库 - 我有兄弟目录“\ x32 \ ImageHlp.Lib”和“\ x64 \ ImageHlp.Lib”。 –