0

I'm trying to add Google Breakpad (some external framework) support to my application. I have done all the required steps, but when I try to load my application using dlopen, I get this error:

(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"

I checked and the Breakpad file does indeed exist in the relative path (to the MyApp file).

Here's the otool -L on the MyApp file (notice the @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)

Anyone has a clue?

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
Tsury
  • 729
  • 1
  • 9
  • 24
  • How have you built MyApp and included the framework? and why and how used dlopen? – mmmmmm Sep 07 '14 at 20:34
  • I included the framework. It is added to the Frameworks folder and to a Copy Files stage that copies it into Frameworks. Also, I can find it in /Contents/Frameworks/Breakpad.framework – Tsury Sep 07 '14 at 20:40
  • I am using dlopen because my application has a wrapper that loads it. – Tsury Sep 07 '14 at 20:40

2 Answers2

0

Follow this steps, It may work:

  1. go to Target then press Build Phase
  2. left top of this page you will find + symbol, press this symbol.
  3. press New Copy Files Build Phase
  4. expand copy file then Drag you framework and drop in this section.
  5. Change the Destination to frameworks

Hope it will Work

Faisal Ikwal
  • 703
  • 3
  • 8
  • 25
0

Well, it turns out it was a problem when using dynamic libraries and compiling for OS X 10.6. The @executable_path doesn't get updated after the dynamic load and thus the LOADED binary is looking for its dependencies relative to the LOADING binary.

I ended up recompiling my framework, Breakpad, and using @loader_path instead of @executable_path, and now everything works just fine.

More info here: dylib @executable_path path issue in a plug-in bundle

Community
  • 1
  • 1
Tsury
  • 729
  • 1
  • 9
  • 24