简体   繁体   English

在Mac OS X上构建Google Breakpad

[英]Building Google Breakpad on Mac OS X

I am attempting to build Google Breakpad for Mac OS X as a part of porting an application, based on the trunk revision 782. 我正在尝试基于主干版本782为Mac OS X构建Google Breakpad作为移植应用程序的一部分。

The Breakpad wiki specifies that one should build client/mac/Breakpad.xcodeproj, which produces a Breakpad.framework including a dynamically linked lib if I understand correctly. Breakpad wiki指定应该构建client / mac / Breakpad.xcodeproj,如果我理解正确,它会产生一个包含动态链接库的Breakpad.framework。 There is also sample code on how to use this from an Objective-C application, but all this seem very different from what seems to be the normal way of doing things on other platforms, including the use of plists and other things that are not part of my application. 还有关于如何在Objective-C应用程序中使用它的示例代码,但所有这些似乎与在其他平台上执行操作的正常方式非常不同,包括使用plist和其他不属于的东西我的申请 I would much rather do things as similar as possible across platforms. 我更愿意跨平台做尽可能相似的事情。

For instance, this appears to be the way that Firefox uses Breakpad: 例如, 似乎是Firefox使用Breakpad的方式:

// include exception_handler.h from client/<platform>/handler,
// using ... here for brevity
#include "... exception_handler.h"
...
gExceptionHandler = new google_breakpad::
    ExceptionHandler(tempPath.get(),
                     nsnull,
                     MinidumpCallback,
                     nsnull,
#if defined(XP_WIN32)
                     google_breakpad::ExceptionHandler::HANDLER_ALL);
#else
                     true);
#endif

In my project, we are doing the same thing and just link against exception_handler.lib on Windows. 在我的项目中,我们正在做同样的事情,只是链接到Windows上的exception_handler.lib It seems that on Linux, Breakpad generates a corresponding libbreakpad_client.a that can be linked against in the same way, but not on Mac OS X. If I do 似乎在Linux上,Breakpad会生成相应的libbreakpad_client.a ,它可以以相同的方式链接,但不能在Mac OS X上链接。如果我这样做

./configure
make

from the breakpad root directory a libbreakpad.a is generated that does not contain the exception handler, and the libbreakpad_client.a that should is not being built. 从该breakpad根目录libbreakpad.a产生不包含异常处理程序,这应该不是正在修建的libbreakpad_client.a。 I may very well have misunderstood just about anything on both the normal way of using Breakpad as well as the normal procedure for building external libraries on the Mac, so any help is appreciated. 我很可能误解了使用Breakpad的正常方式以及在Mac上构建外部库的正常程序,所以任何帮助都会受到赞赏。

How do I build libbreakpad_client.a on Mac OS X? 如何在Mac OS X上构建libbreakpad_client.a

This might not be helpful in your case, but I've found this to work for a project I'm working on that needs to work on both Linux and OSX. 这可能对您的情况没有帮助,但我发现这适用于我正在开发的项目,需要在Linux和OSX上运行。 On Linux we use the "normal" autotools way of doing things; 在Linux上,我们使用“正常”的autotools做事方式; on OSX we invoke xcodebuild to create Breakpad.framework and then link against that. 在OSX上,我们调用xcodebuild来创建Breakpad.framework ,然后链接到它。

Here's the relevant portion of the CMakeLists.txt file ( for CMake see here ): 这是CMakeLists.txt文件的相关部分( 对于CMake,请参见此处 ):

IF(LINUX)
  add_custom_target(
    GOOGLE_BREAKPAD_MAKEFILE
    COMMAND cd ../google-breakpad/ && ([ -e Makefile ] || (autoreconf && bash configure))
  )
  add_custom_target(
    GOOGLE_BREAKPAD
    COMMAND cd ../google-breakpad/ && $(MAKE)
  )
  add_dependencies(GOOGLE_BREAKPAD GOOGLE_BREAKPAD_MAKEFILE)
ENDIF()

IF(APPLE)
  add_custom_target(
    GOOGLE_BREAKPAD
    COMMAND cd ../google-breakpad/src/client/mac/ && xcodebuild -sdk macosx
  )
ENDIF()

If your application is built with clang -stdlib=libc++ (which is pretty normal if you make heavy use of C++11), you should append the phrase GCC_VERSION=com.apple.compilers.llvm.clang.1_0 OTHER_CFLAGS=-stdlib=libc++ OTHER_LDFLAGS=-stdlib=libc++ to the end of the xcodebuild line. 如果您的应用程序是使用clang -stdlib=libc++构建的(如果您大量使用C ++ 11,这是很正常的),您应该附加短语GCC_VERSION=com.apple.compilers.llvm.clang.1_0 OTHER_CFLAGS=-stdlib=libc++ OTHER_LDFLAGS=-stdlib=libc++xcodebuild行的末尾。 This will force xcodebuild to do the right thing. 这将迫使xcodebuild做正确的事情。

If your application is built with GCC and GNU libstdc++, you don't need to add anything to the xcodebuild line. 如果您的应用程序是使用GCC和GNU libstdc ++构建的,则无需向xcodebuild行添加任何内容。

There is no solution in the Breakpad source for this, unfortunately. 遗憾的是,Breakpad源代码中没有解决方案。 The XCode projects simply build the Breakpad framework, as that's the more-supported client API. XCode项目只是构建Breakpad框架,因为这是支持更多的客户端API。 You can build the code with your own set of Makefiles or whatever build setup you desire the same way Firefox does by looking at the set of Mozilla makefiles: 您可以使用自己的Makefile集或任何构建设置来构建代码,就像Firefox通过查看Mozilla makefile集一样:

http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/Makefile.in http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/Makefile.in

http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in

http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/Makefile.in http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/Makefile.in

http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/mac/handler/Makefile.in http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/mac/handler/Makefile.in

http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/Makefile.in http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/Makefile.in

and gathering the set of files referenced in CSRCS/CPPSRCS/CMSRCS/CMMSRCS, and building all of those. 并收集CSRCS / CPPSRCS / CMSRCS / CMMSRCS中引用的文件集,并构建所有这些文件。

You might also file a bug in the Breakpad issue tracker to ask that the XCode project build this static library as well. 您可能还会在Breakpad问题跟踪器中提交一个错误,要求XCode项目也构建此静态库。 It would not be a difficult patch. 这不是一个困难的补丁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM