0

我正在尝试将 Google Breakpad(一些外部框架)支持添加到我的应用程序中。我已经完成了所有必需的步骤,但是当我尝试使用 dlopen 加载我的应用程序时,我收到了这个错误:

(char *) error = 0x0000000100200175 "dlopen(/Users/user/MyApp.app/Contents/MacOS/MyApp, 1): 
Library not loaded: @executable_path/../Frameworks/Breakpad.framework/Versions/A/Breakpad\n  
Referenced from: /Users/user/MyApp.app/Contents/MacOS/MyApp\n  
Reason: image not found"

我检查了一下,Breakpad 文件确实存在于相对路径(到 MyApp 文件)中。

这是 MyApp 文件上的 otool -L (注意@executable_path):

Users-Mac:MacOS user$ otool -L MyApp 
MyApp:
    /usr/lib/libcurl.4.dylib (compatibility version 6.0.0, current version 6.1.0)
    /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)
    /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
    /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../Frameworks/Breakpad.framework/Versions/A/Breakpad (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 152.0.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
    /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/CoreAudioKit.framework/Versions/A/CoreAudioKit (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI (compatibility version 1.0.0, current version 49.0.0)
    /System/Library/Frameworks/DiscRecording.framework/Versions/A/DiscRecording (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.6.3)
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 533.21.1)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.43.0)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.36.0)
    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
    /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.62.0)

有人有线索吗?

4

2 回答 2

0

请按照以下步骤操作,它可能会起作用:

  1. 转到目标然后按构建阶段
  2. 这个页面的左上角你会发现+符号,按这个符号。
  3. 新建复制文件构建阶段
  4. 展开复制文件,然后将您的框架拖放到此部分中。
  5. 将目标更改为框架

希望它会工作

于 2014-09-08T07:45:10.687 回答
0

好吧,事实证明,在使用动态库和为 OS X 10.6 编译时,这是一个问题。@executable_path 在动态加载后不会更新,因此 LOADED 二进制文件正在寻找其相对于 LOADING 二进制文件的依赖项。

我最终重新编译了我的框架 Breakpad,并使用 @loader_path 而不是 @executable_path,现在一切正常。

更多信息: dylib @executable_path 插件包中的路径问题

于 2014-09-08T11:40:16.917 回答