I'm developing a Mac OS X Cocoa app and want to use several .dylib libraries. How do I set the path to a .dylib which resides somewhere in my Application folder? What if the path resides in different directories on different computers or is not existent at all?
+1
A:
which resides somewhere in my Application folder?
Use @rpath
. (or @executable_path
.) See man 1 dyld
.
What if the path resides in different directories on different computers or is not existent at all?
Then your app will fail to load. Use weak linking or load the dylib at runtime with dlopen
if the dylib is not essential.
KennyTM
2010-03-05 14:09:58
How can I tell the user that a .dylib is missing when using dlopen?
Sney
2010-03-05 14:34:02
`dlopen` will return `NULL` if the dylib is missing or invalid. (And you can check if a file exist or not with `fstat`...)
KennyTM
2010-03-05 14:40:17