将Qt应用程序链接到Google Breakpad时出现未解决的符号错误

我试图将我的Qt应用程序静态链接到Windows下的Google Breakpad,但我总是得到未解决的符号错误。我正在使用qmake和VC ++ 2008,我的项目文件似乎有些问题。似乎链接器忽略了我的LIBS规范,因为无论我是否将库添加到LIBS,我都会收到错误。 我用以下方法编译了Breakpad:
vcbuild /platform:Win32
Google Breakpead在src processor test_app.cc中包含一个示例。如果我按照建议编译它,一切都很顺利:
C:test>cl /Zi test_app.cc /Fetest_app.exe /I C:google-breakpadsrc C:google-breakpadsrcclientwindowsReleaselibexception_handler.lib C:google-breakpadsrcclientwindowsReleaselibcrash_generation_client.lib C:google-breakpadsrcclientwindowsReleaselibcommon.lib
但是,如果我尝试使用类似的.pro文件使用qmake构建它,我会得到相同的未解决的符号错误。这是我用来的.pro文件:
TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += C:/google-breakpad/src
SOURCES += test_app.cc

LIBS += C:/google-breakpad/src/client/windows/Release/lib/exception_handler.lib
LIBS += C:/google-breakpad/src/client/windows/Release/lib/crash_generation_client.lib
LIBS += C:/google-breakpad/src/client/windows/Release/lib/common.lib
PRE_TARGETDEPS += C:/google-breakpad/src/client/windows/Release/lib/exception_handler.lib
PRE_TARGETDEPS += C:/google-breakpad/src/client/windows/Release/lib/crash_generation_client.lib
PRE_TARGETDEPS += C:/google-breakpad/src/client/windows/Release/lib/common.lib
建立它:
C:test>qmake -config release

C:test>nmake

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:Program filesMicrosoft Visual Studio 9.0VCBINnmake.exe" -
f Makefile.Release

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189
-DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQ
T_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAV
E_SSE2 -DQT_THREAD_SUPPORT -I"..Qt4.7.1includeQtCore" -I"..Qt4.7.1include
QtGui" -I"..Qt4.7.1include" -I"." -I"..google-breakpadsrc" -I"..Qt4.7.1
includeActiveQt" -I"release" -I"..Qt4.7.1mkspecswin32-msvc2008" -Forelease
 @C:WindowsTempnm94.tmp
test_app.cc
.test_app.cc(43) : warning C4100: 'assertion' : unreferenced formal parameter
.test_app.cc(42) : warning C4100: 'exinfo' : unreferenced formal parameter
.test_app.cc(42) : warning C4100: 'context' : unreferenced formal parameter
.test_app.cc(41) : warning C4100: 'dump_path' : unreferenced formal parameter
.test_app.cc(62) : warning C4100: 'argv' : unreferenced formal parameter
.test_app.cc(62) : warning C4100: 'argc' : unreferenced formal parameter
        link /LIBPATH:"c:Qt4.7.1lib" /NOLOGO /INCREMENTAL:NO /MANIFEST /MANIF
ESTFILE:"releasetest.intermediate.manifest" /SUBSYSTEM:WINDOWS "/MANIFESTDEPEND
ENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' pub
licKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /OUT:rele
asetest.exe @C:WindowsTempnm95.tmp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; us
e /NODEFAULTLIB:library
test_app.obj : error LNK2019: unresolved external symbol "public: __thiscall goo
gle_breakpad::ExceptionHandler::ExceptionHandler(class std::basic_string<unsigne
d short,struct std::char_traits<unsigned short>,class std::allocator<unsigned sh
ort> > const &,bool (__cdecl*)(void *,struct _EXCEPTION_POINTERS *,struct MDRawA
ssertionInfo *),bool (__cdecl*)(unsigned short const *,unsigned short const *,vo
id *,struct _EXCEPTION_POINTERS *,struct MDRawAssertionInfo *,bool),void *,int)"
 (??0ExceptionHandler@google_breakpad@@QAE@ABV?$basic_string@GU?$char_traits@G@s
td@@V?$allocator@G@2@@std@@P6A_NPAXPAU_EXCEPTION_POINTERS@@PAUMDRawAssertionInfo
@@@ZP6A_NPBG5123_N@Z1H@Z) referenced in function _main
releasetest.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:Program filesMicrosoft Visual Studio 9.0VCBIN
link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:Program filesMicrosoft Visual Studio 9.0VCBIN
nmake.exe"' : return code '0x2'
Stop.
我在.pro文件中缺少什么? 提前致谢。     
已邀请:
问题是Google Breakpad库编译时启用了“将wchar_t作为内置类型处理”(
/Zc:wchar_t
)。 Qt编译禁用该选项(
/Zc:wchar_t-
)。这意味着在编译时,所有内容都匹配:
std::wstring
unsigned short
定义,这是Qt所期望的。但是在链接时,Breakpad库以
__wchar_t
(或
wchar_t
)定义了
wstring
。结果是链接器无法解析对其函数的调用,因为参数类型不匹配(在链接时)。 解决方案是: 禁用Google Breakpad库中的“将wchar_t视为内置类型”(在“配置属性”>“C / C ++”>“语言”下。(这是我们正在尝试的...) 启用Qt中的选项(删除
/Zc:wchar_t-
) 欲获得更多信息: / Zc:wchar_t(wchar_t是本机类型) (这个很微妙;让我们在一天中的大部分时间都难过了。)     

要回复问题请先登录注册