Search code examples
macoslinkerstatic-linking

dyld: Library not loaded: /opt/local/lib/libglib-2.0.0.dylib


I've gotten MDB-Tools compiled for OSX, but when I try to run a sample command line program on another computer I get this error:

dyld: Library not loaded: /opt/local/lib/libglib-2.0.0.dylib Referenced from: /Users/dev/mdb/mdb-test Reason: image not found Trace/BPT trap: 5

I believe that this means that the target system is missing a library and I think its something to do with linkage, but I'm not exactly positive how to go about fixing this. Could anyone point me in the right direction?


Solution

  • The /opt/local directory is typically used by MacPorts. Your compiled program has a dependency on glib from MacPorts. You either need to install that on the machines where you want to run your program or you need to bundle together your program and all of the libraries it depends on.

    Check Apple's Dynamic Library Programming Topics.