4

Windows で Qt アプリケーションを 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-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)"
 (??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
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 ファイルには何がありませんか?

前もって感謝します。

4

1 に答える 1

6

問題は、Google ブレークパッド ライブラリが [組み込み型として wchar_t を扱う] を有効にしてコンパイルされていることです ( /Zc:wchar_t)。Qt は、そのオプションを無効にしてコンパイルします ( /Zc:wchar_t-)。これは、コンパイル時に 、すべてが一致することを意味します。std::wstringは の観点から定義されておりunsigned short、これは Qt が期待するものです。しかし、リンク時に、Breakpad ライブラリは(または)wstringに関して定義されています。その結果、(リンク時に)パラメーターの型が一致しないため、リンカーは関数への呼び出しを解決できません。__wchar_twchar_t

解決策は次のいずれかです。

  • Google ブレークパッド ライブラリ ([構成プロパティ] > [C/C++] > [言語] の下) の [wchar_t を組み込み型として扱う] を無効にします (これは私たちが試みていることです...)
  • Qt でオプションを有効にする (削除/Zc:wchar_t-)

詳細については:

(これは微妙です。1 日の大半を悩ませていたのでしょうか。)

于 2011-02-10T14:46:36.687 に答える