1

After a few hours of digging for this linker error, it wasn't successful:(

Steps to reproduce:

  1. Install gyp and it to PATH
  2. Open VS2015 x86 Native Tools Command Prompt
  3. Run:
    • git clone https://chromium.googlesource.com/breakpad/breakpad && cd breakpad
    • cd src && git clone https://github.com/google/googletest testing && cd ..
    • gyp -–no-circular-check src\client\windows\breakpad_client.gyp
  4. Open src\client\windows\breakpad_client.sln
  5. Go to projects Properties>C/C++/General and change Treat Warnings As Errors to No for crash_generation_client, common, exception_handler for Debug and Release configuration
  6. Go to projects Properties>C/C++/General and change Treat wchar_t as Built-in Type to No for crash_generation_client, common, exception_handler for Debug and Release configuration
  7. Buil all for Debug
  8. Build all for Release
  9. Link the libs located in breakpad\src\client\windows\Debug\lib and breakpad\src\client\windows\Release\lib to your application, in my case the Qt qmake file like below:
win32:debug {
    BREAKPAD_PATH = $$PWD/../../../LIBS/breakpad
    INCLUDEPATH += $$BREAKPAD_PATH/src
    LIBS += -L$$BREAKPAD_PATH/client/windows/Debug/lib/crash_generation_client.lib
    LIBS += -L$$BREAKPAD_PATH/client/windows/Debug/lib/exception_handler.lib
    LIBS += -L$$BREAKPAD_PATH/client/windows/Debug/lib/common.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Debug/lib/crash_generation_client.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Debug/lib/exception_handler.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Debug/lib/common.lib
} else:release {
    BREAKPAD_PATH = $$PWD/../../../LIBS/breakpad
    INCLUDEPATH += $$BREAKPAD_PATH/src
    LIBS += -L$$BREAKPAD_PATH/client/windows/Release/lib/crash_generation_client.lib
    LIBS += -L$$BREAKPAD_PATH/client/windows/Release/lib/exception_handler.lib
    LIBS += -L$$BREAKPAD_PATH/client/windows/Release/lib/common.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Release/lib/crash_generation_client.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Release/lib/exception_handler.lib
    PRE_TARGETDEPS += $$BREAKPAD_PATH/client/windows/Release/lib/common.lib
}
  1. The linker should prompt you by the following error:

    crash_handler.obj : error LNK2019: unresolved external symbol "public: __thiscall google_breakpad::ExceptionHandler::ExceptionHandler(class std::basic_string,class std::allocator > const &,bool (__cdecl*)(void *,struct _EXCEPTION_POINTERS *,struct MDRawAssertionInfo ),bool (__cdecl)(wchar_t const *,wchar_t const *,void *,struct _EXCEPTION_POINTERS *,struct MDRawAssertionInfo *,bool),void *,int)" (??0ExceptionHandler@google_breakpad@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@P6A_NPAXPAU_EXCEPTION_POINTERS@@PAUMDRawAssertionInfo@@@ZP6A_NPB_W5123_N@Z1H@Z) referenced in function "public: void __thiscall breakpad::CrashHandlerPrivate::initCrashHandler(class QString const &)" (?initCrashHandler@CrashHandlerPrivate@breakpad@@QAEXABVQString@@@Z) crash_handler.obj : error LNK2019: unresolved external symbol "public: __thiscall google_breakpad::ExceptionHandler::~ExceptionHandler(void)" (??1ExceptionHandler@google_breakpad@@QAE@XZ) referenced in function "public: void * __thiscall google_breakpad::ExceptionHandler::`scalar deleting destructor'(unsigned int)" (??_GExceptionHandler@google_breakpad@@QAEPAXI@Z) crash_handler.obj : error LNK2019: unresolved external symbol "public: bool __thiscall google_breakpad::ExceptionHandler::WriteMinidump(void)" (?WriteMinidump@ExceptionHandler@google_breakpad@@QAE_NXZ) referenced in function "public: bool __thiscall breakpad::CrashHandler::writeMinidump(void)" (?writeMinidump@CrashHandler@breakpad@@QAE_NXZ)

crash_handler.h:

#ifndef _CRASH_HANDLER_H
#define _CRASH_HANDLER_H

namespace breakpad {

    class CrashHandlerPrivate;

    class CrashHandler {
    public:
        static CrashHandler* instance();
        void init(const QString&  reportPath);

        void setReportCrashesToSystem(bool report);
        bool writeMinidump();

    private:
        CrashHandler();
        ~CrashHandler();

    private:
        CrashHandlerPrivate* d;
        Q_DISABLE_COPY(CrashHandler)
    };

} // namespace breakpad

#endif // !_CRASH_HANDLER_H

crash_handler.cpp

#include "crash_handler.h"

#if defined(Q_OS_LINUX)
#include "client/linux/handler/exception_handler.h"
#elif defined(Q_OS_WIN32)
#include "client/windows/handler/exception_handler.h"
#endif

namespace breakpad {

    class CrashHandlerPrivate {
    public:
        CrashHandlerPrivate() {
            pHandler = NULL;
        }

        ~CrashHandlerPrivate() {
            delete pHandler;
        }

        void initCrashHandler(const QString& dumpPath);

    public:
        static google_breakpad::ExceptionHandler* pHandler;
        static bool bReportCrashesToSystem;
    };

    google_breakpad::ExceptionHandler* CrashHandlerPrivate::pHandler = NULL;
    bool CrashHandlerPrivate::bReportCrashesToSystem = false;

    /************************************************************************/
    /* DumpCallback                                                         */
    /************************************************************************/
#if defined(Q_OS_WIN32)
    bool DumpCallback(const wchar_t* _dump_dir, const wchar_t* _minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool success)
#elif defined(Q_OS_LINUX)
    bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context, bool success)
#endif
    {
        Q_UNUSED(context);
#if defined(Q_OS_WIN32)
        Q_UNUSED(_dump_dir);
        Q_UNUSED(_minidump_id);
        Q_UNUSED(assertion);
        Q_UNUSED(exinfo);
#endif
        qDebug("BreakpadQt crash");

        /*
        NO STACK USE, NO HEAP USE THERE !!!
        Creating QString's, using qDebug, etc. - everything is crash-unfriendly.
        */
        return CrashHandlerPrivate::bReportCrashesToSystem ? success : true;
    }

    void CrashHandlerPrivate::initCrashHandler(const QString& dumpPath)
    {
        if (pHandler != NULL)
            return;

#if defined(Q_OS_WIN32)
        std::wstring pathAsStr = (const wchar_t*)dumpPath.utf16();
        pHandler = new google_breakpad::ExceptionHandler(
            pathAsStr,
            /*FilterCallback*/ 0,
            DumpCallback,
            /*context*/
            0,
            true
        );
#elif defined(Q_OS_LINUX)
        std::string pathAsStr = dumpPath.toStdString();
        google_breakpad::MinidumpDescriptor md(pathAsStr);
        pHandler = new google_breakpad::ExceptionHandler(
            md,
            /*FilterCallback*/ 0,
            DumpCallback,
            /*context*/ 0,
            true,
            -1
        );
#endif
    }



    CrashHandler* CrashHandler::instance() {
        static CrashHandler globalHandler;
        return &globalHandler;
    }

    CrashHandler::CrashHandler() {
        d = new CrashHandlerPrivate();
    }

    CrashHandler::~CrashHandler() {
        delete d;
    }

    void CrashHandler::setReportCrashesToSystem(bool report) {
        d->bReportCrashesToSystem = report;
    }

    bool CrashHandler::writeMinidump() {
        bool res = d->pHandler->WriteMinidump();
        if (res) {
            qDebug("BreakpadQt: writeMinidump() success.");
        } else {
            qWarning("BreakpadQt: writeMinidump() failed.");
        }
        return res;
    }

    void CrashHandler::init(const QString& reportPath) {
        d->initCrashHandler(reportPath);
    }

} // namespace breakpad

Really don't know what the problem is ?!

Configuration:

  • OS: Windows 10(1809)

  • Build system: MSVC14.0(2015)

  • Qt version: 5.8(32bit)

SergeyA
  • 61,605
  • 5
  • 78
  • 137
IMAN4K
  • 1,265
  • 3
  • 24
  • 42
  • Removing C++ tag as question really has nothing to do with C++. It is a question for breakpad support. – SergeyA Aug 16 '19 at 17:48
  • @IMAN4K running into the same issue, were you able to get past it? – vava044 May 19 '21 at 11:39
  • I'm away from the win32 platform for a quite long time, but make sure you build the breakpad properly as mentioned here https://github.com/telegramdesktop/tdesktop/blob/v2.4.13/docs/building-msvc.md#clone-source-code-and-prepare-libraries and the rest is to link to it – IMAN4K May 20 '21 at 04:01

0 Answers0