dyld fatal error in Xcode OSX

I’ve just started my first project with the low-level api in Xcode on OS X using the C++ command line tool project type.

I basically copied the whole FMOD download folder for Mac OS X into my project folder.

I created a ‘Group’ in Xcode project hierarchy called ‘Libraries’ where I added the debug/release versions of the FMOD libs. (This has the effect of updating ‘Link Binaries With Libraries’ section of Build Phases for my target.

I then updated the following Build Settings for my project:

  • Linking → Other Linker Flags = “FMOD Programmers API/api/lowlevel/lib/libfmodL.dylib” (Debug)
  • Linking → Other Linker Flags = “FMOD Programmers API/api/lowlevel/lib/libfmod.dylib” (Release)
  • Search Paths → Header Search Paths = “FMOD Programmers API/api/lowlevel/inc”

The project builds successfully, but when I run I get the following error:

dyld`dyld_fatal_error

dyld: Library not loaded: @rpath/libfmodL.dylib Referenced from:
/Users/simonbosley/Documents/Programming/DiceInvaders/DerivedData/DiceInvaders/Build/Products/Debug/DiceInvaders
Reason: image not found (lldb)

If I place a breakpoint on the first line of code in my main function entry-point, it doesn’t even reach it.

I can’t see how my project differs from the examples provided, am I missing something?

Do you get this error when you run the examples? If not perhaps comparing the examples to your project will yield some more info.

The examples build and run as expected. I’ve edited my post above, detailing with more information. What have I missed?

I’ve also added that I created a c++ command line tool project, if that helps?

So it seems you must add a “Build Phases --> Copy Files” section, to copy both debug and release fmod libs. I’ve copied the libs to the executables directory and this works for me. I’ve noticed on the examples provided, it copies the libraries to the Frameworks directory, I guess because it’s an app.

You’ll notice in the dyld (runtime linker) error it cannot find @rpath/libfmodL.dylib.

The examples specify the rpath as one of the build settings:
LD_RUNPATH_SEARCH_PATHS = “@loader_path/…/Frameworks”

You can set this to whatever you like, or you can use install_name_tool to fix up the references post build. You do need to make sure the FMOD dylibs are copied somewhere referenced by your executable or you will get the “image not found” errors.