🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

MacOS X Newbie Part2

Started by
0 comments, last by Bregma 16 years, 4 months ago
I am have pretty much the exact same problems as cubicwang when it comes to running the app by double clicking it. http://www.gamedev.net/community/forums/topic.asp?topic_id=387729&forum_id=14&gforum_id=0 "2. My project have some targets in it. One is a application and the other is the dylib.When I runing the program in the XCODE debug tools it will be OK, but if I want to run it by just double click the .app, it can not run.I think that because the dylib have not been linked without the debug tool.But I don't known what to do." The thing is I'm trying to static link with FMOD's libfmodex.dylib. I've followed the suggestions in that thread (using Release build, and removing zero link), but when I double click my app, I get this error: brian-jones-computer:~ brianjones$ /Users/brianjones/Programming/FMOD\ Test/build/Release/FMOD\ Test; exit dyld: Library not loaded: ./libfmodex.dylib Referenced from: /Users/brianjones/Programming/FMOD Test/build/Release/FMOD Test Reason: image not found Trace/BPT trap libfmodex.dylib is in the same folder as the executable. I also set "/Developer/FMOD Programmers API/api/lib" to Library Search Path in XCode. I might think it's this as I'm not terribly familiar with Unix file paths. In Windows everything is relative to C:/, but in Mac OS I think everything is relative to Macintosh HD. Someone pointed me to this: http://blog.onesadcookie.com/2008/01/installname-magic.html I don't even know where to begin with that. I thought a IDE was supposed to hide the complexities of dealing with the compiler directly. Can someone please help, cause this is frustrating as none of my books (Beginning Xcode or Programming in Objective-C) shows anything about linking and apples website says pretty much nothing about linking to dylibs.
Advertisement
Quote: Original post by Knuckler
"2. My project have some targets in it. One is a application and the other is the dylib.When I runing the program in the XCODE debug tools it will be OK, but if I want to run it by just double click the .app, it can not run.I think that because the dylib have not been linked without the debug tool.But I don't known what to do."

The thing is I'm trying to static link with FMOD's libfmodex.dylib. I've followed the suggestions in that thread (using Release build, and removing zero link), but when I double click my app, I get this error:

Woah, wait a minute. You can't static link a dylib. A dylib is a dynamic library loadable only by the runtime linkloader.

Your goal is to have the runtime linkloader find the dylib and load it at program startup.
Quote:
brian-jones-computer:~ brianjones$ /Users/brianjones/Programming/FMOD\ Test/build/Release/FMOD\ Test; exit
dyld: Library not loaded: ./libfmodex.dylib
Referenced from: /Users/brianjones/Programming/FMOD Test/build/Release/FMOD Test
Reason: image not found
Trace/BPT trap

libfmodex.dylib is in the same folder as the executable.

The runtime linkloader does not normally look in (a) te current working directory or (2) the same directory as the executable. You will have to specify somewhere the place for the runtime linkloader to look to find the dylib. As a test, there is an environment variable you can set at the command line (I admit to being rusty on OS X, but I think it's something like DYLIB_LIBRARY_PATH -- the manpage will tell you). Set that variable to contain the path to the directory containing the dylib and see it that helps.

As a permanent solution, it's possible all you have to do is edit the .xml file in your application bundle to include the path. Apple has plenty of docs to wade through on what goes in an application bundle (as I said, I'm a little rusty).
Quote: I also set "/Developer/FMOD Programmers API/api/lib" to Library Search Path in XCode.

I believe that does not affect the runtime linkloading.
Quote: I might think it's this as I'm not terribly familiar with Unix file paths. In Windows everything is relative to C:/, but in Mac OS I think everything is relative to Macintosh HD.
In a POSIX (Unix) system, absolute paths are relative to /, the root of the filesystem. There is no distibuishing between drives. I think your confusion comes from the fact that the dynamic linkloader does not look by default in the current working directory or the directory containing the executable when looking for a .dylib (or, on other Unix systems, a .so file). You either have to tell it explicitly or else drop your library in one of the standard places (eg. /Libraries). As well, the MACH-O system supports multiarchitecture dylib bundles, so a dylib isn't necessarily a single file but might be an entire directory bundle.

Your best be is to find documentation of dylibs at Apple and become an expert on the MACH-O linkloader model and Mac OS X bundle architecture.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement