2010-12-22 77 views
4

我试图将我的Qt应用程序静态链接到Windows下的Google Breakpad,但我总是得到未解决的符号错误。我正在使用qmake和VC++ 2008,并且似乎与我的项目文件有一些问题。这似乎是如果链接器忽略了我的LIBS规范,因为无论我是否将库添加到LIBS中,都会收到错误。将Qt应用程序链接到Google Breakpad时未解决的符号错误

我使用编译Breakpad:

vcbuild /platform:Win32 

谷歌Breakpead包括SRC \处理器\ test_app.cc一个例子。如果我编译它的建议,一切顺利:

C:\test>cl /Zi test_app.cc /Fetest_app.exe /I C:\google-breakpad\src C:\google-breakpad\src\client\windows\Release\lib\exception_handler.lib C:\google-breakpad\src\client\windows\Release\lib\crash_generation_client.lib C:\google-breakpad\src\client\windows\Release\lib\common.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 files\Microsoft Visual Studio 9.0\VC\BIN\nmake.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"..\Qt\4.7.1\include\QtCore" -I"..\Qt\4.7.1\include 
\QtGui" -I"..\Qt\4.7.1\include" -I"." -I"..\google-breakpad\src" -I"..\Qt\4.7.1\ 
include\ActiveQt" -I"release" -I"..\Qt\4.7.1\mkspecs\win32-msvc2008" -Forelease\ 
@C:\Windows\Temp\nm94.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:\Qt\4.7.1\lib" /NOLOGO /INCREMENTAL:NO /MANIFEST /MANIF 
ESTFILE:"release\test.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 
ase\test.exe @C:\Windows\Temp\nm95.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)" 
([email protected][email protected]@[email protected][email protected][email protected]@s 
[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@PAUMDRawAssertionInfo 
@@@[email protected]@Z) referenced in function _main 
release\test.exe : fatal error LNK1120: 1 unresolved externals 
NMAKE : fatal error U1077: '"C:\Program files\Microsoft Visual Studio 9.0\VC\BIN 
\link.EXE"' : return code '0x460' 
Stop. 
NMAKE : fatal error U1077: '"C:\Program files\Microsoft Visual Studio 9.0\VC\BIN 
\nmake.exe"' : return code '0x2' 
Stop. 

什么我在.pro文件丢失?

在此先感谢。

+0

我们遇到了同样的问题。你找到了解决方案吗? – 2011-02-09 19:43:56

+1

顺便说一句,要摆脱defaultlib警告,您必须更改Breakpad项目以使用多线程DLL运行时库(/ MD for release或/ MDd for debug)。 – 2011-02-10 14:52:40

回答

5

问题在于Google Breakpad库是在启用“Treat wchar_t as Built-in Type”的情况下编译的(/Zc:wchar_t)。 Qt编译时禁用了该选项(/Zc:wchar_t-)。这意味着在编译时间,所有内容都匹配:std::wstring根据unsigned short定义,这是Qt所期望的。但是在链接时间处,Breakpad库已经根据__wchar_t(或wchar_t)定义了wstring。其效果是,链接器无法解决您自己的函数调用,因为参数类型不匹配

的解决方法是(在链接时):

  • 禁用“治疗wchar_t的作为谷歌Breakpad库内置型”(下配置属性> C/C++>语言。(这是我们正在努力...)
  • 启用Qt的选项(删除/Zc:wchar_t-

有关详细信息:

(这一个是微妙;让我们在一天的大部分时间里难倒了)。

相关问题