0
0

Edit: here is the final solution, so you don’t have to read the whole topic!

Hopefully these instructions are sort of the same for Xcode 2:

1) In the Project menu, choose Edit Active Target [app name]
2) In the list on the left side of the window, right click (control click) on "Build Phases" and choose "New Build Phase" > "New Shell Script Build Phase"
3) Under build phases now should be an item called "Shell Script Files". Click on that, and on the right there are two fields. In the lower, unlabeled one, enter the following command:

install_name_tool -change libfmodex.dylib @executable_path/wherever/libfmodex.dylib ~/ProjectFolder/build/MyApp.app/Contents/MacOS/MyApp

Where "wherever" is the path to wherever you want to keep libfmodex.dylib, relative to the actual executable inside the application bundle, and the following line is the path to said executable. For the former a good idea might be to put libfmodex.dylib inside the app bundle somewhere, like Contents/Frameworks or something (so the argument for that would be "@executable_path/../Frameworks"), so that the program is self-contained (right click > "show package contents" to open the app bundle). Xcode won’t mess with it unless you clean or something.

4) Drag "Shell Script Files" to the bottom of the build sequence. (?) I suspect that this is necessary, as you want to alter the executable after it has been built.

The original post follows:


Alas, I do not have Xcode 2.1 since I have no Macs with DVD drives and/or 512 MB RAM to install Mac OS X 10.4. (And apple rips you off if you want Tiger on CD.)

Anyway I’ve managed to include the FMOD Ex headers without incident and add libfmodex.dylib to my project, and it compiles just fine. It also runs just fine from within Xcode if I copy the libfmodex.dylib file to my build folder. However it is unable to find that file if I exit Xcode and double-click on the .app itself (instead of clicking "run" in Xcode). I understand the thing to do if I were command-line compiling would be the install-whatever command I see in the example makefiles. But I’m in Xcode, and as yet I can’t find a way to get Xcode to build the .dylib file into the executable.

So does anyone know how to do that? (I am not much of an Xcode expert as you can tell.)

While I’m at it, here are some other problems I’ve encountered: the examples do not run properly when compiled, as they are apparently unable to locate the media they require. I have looked in the code and it really should be working, so perhaps this is fixed with a newer version of gcc? In addition, when playing a sound, the "FMOD_CHANNEL_FREE" flag shown in the examples also would appear to not function as advertised, as when used in my game all sounds share a single channel unless I manually specify a channel index (e.g. FMOD_CHANNELINDEX(1) – the compiler seems to want me to type-cast). Alas, I am quite new to everything.

  • You must to post comments
0
0

Ah, the unlabelled field – big one, yeah? – is where the script goes. That’s where you put the install_name_tool stuff.

In my bundle, I put the dylib in a ‘Frameworks’ folder inside Contents – seems like a reasonable place for all support libraries. You use install_name_tool to fix up the path in the executable to point to the dylib inside that folder (relative to the executable – otherwise it would break the moment someone moves the .app).

  • You must to post comments
0
0

Well I set mine up just like yours and pasted the command, substituting my executable name like so:

install_name_tool -change libfmodex.dylib @executable_path/../Frameworks/libfmodex.dylib ‘Triangle Wars’

No deal, unfortunately. I get a build error that says “see build log for details” – which apparently a mythical file. Because I cannot find it.

  • You must to post comments
0
0

Ah, yeah, that’s what kept me stumped for quite a while. It’s hidden by default – on the Detailed Build Results window, look for four buttons on the left hand side underneath the errors pane (but above the code pane). The third button toggles the build log.

Also, make sure that when you’re specifying your executable name, install_name_tool can find it – that’s the file that it needs to open and modify. I’ve actually hardcoded mine – /Users/Richard/xplatformdemo/build/xplatformdemo.app/Contents/MacOS/xplatformdemo – so if I move the project folder I’ll need to update the script.

  • You must to post comments
0
0

You got it to build? Nice. I can’t even get that far; the linker dies with “Undefined symbol:” but no mention of what symbol it’s actually complaining about. libfmodex.dylib is in my project’s “Frameworks” folder and all the files compile successfully, it’s just the linking that dies… help would be appreciated, I don’t want to have to drop back to plain Fmod :(

  • You must to post comments
0
0

Awesome, works! Thanks a lot!

(my problem was only that I did not realize that “<exename>” really should be the path to the executable if we’re not entering the command from within theapp.app/Contents/MacOS/ already – obvious really)

  • You must to post comments
0
0

Hmm. I did basically the exact same thing. The only difference is in Project > Edit Active Target [app name], I added “/FMOD Programmers API/api/lib” to the library search paths (which is under “settings” near the top, and you have to expand “simple view”; “Libraries” is empty by default).

It shouldn’t matter though; I only added that in the event that I wanted to link via adding the -libfmodex.dylib argument to the linker settings because I was suspicious that the framework adding method was not working, but I never actually did that because it worked (something else was the problem). Oh well, something to try I suppose.

  • You must to post comments
0
0

Edit: Nevermind about my midi problems; just learned about the system->setPluginPath() function.

Not that it seems to work…

  • You must to post comments
0
0

Sadly, that entry is already in my linker search paths.

  • You must to post comments
0
0

You can’t “build the .dylib file into the executable”, it is a dynamic library. You can use the “install-whatever” you see in the Makefiles in Xcode by adding a shell script build phase and putting that command in the script.

  • You must to post comments
0
0

That’s not what I was trying to do; but it doesn’t matter, I’ve found out how to see the build transcript now (telling me exactly which symbol is undefined) and it turns out to have been a problem with my code all along. Sorry to waste your time :)

  • You must to post comments
0
0

[quote="chenpo":qq4vkkll]You can’t “build the .dylib file into the executable”, it is a dynamic library. You can use the “install-whatever” you see in the Makefiles in Xcode by adding a shell script build phase and putting that command in the script.[/quote:qq4vkkll]

Alright thanks, I can see how to do that in Xcode, or rather I can see where the functionality is. What I can’t see is how exactly to implement the script, but that’s because I don’t know anything about shell scripts… Well I will find out somehow.

  • You must to post comments
0
0

What I did was this:

[list:13dghhzq]
[:13dghhzq]Select desired target[/:m:13dghhzq]
[:13dghhzq]Project->New Build Phase->New Shell Script Phase[/:m:13dghhzq]
[:13dghhzq]Get Info on the new phase[/:m:13dghhzq]
[:13dghhzq]Write a single-command script that uses install_name_tool to update the library path[/:m:13dghhzq][/list:u:13dghhzq]

What happens is that your executable gets the paths to all the libraries that it’s using written into it – you can use “otool -l <exename>” to see what’s there. Doing “install_name_tool -change libfmodex.dylib @executable_path/../Frameworks/libfmodex.dylib <exename>” updates this table, finding the ‘libfmodex.dylib’ entry in it and replacing it with the @executable_path string (which is the only way to do relative paths – use with bundles, ideally).

  • You must to post comments
0
0

Alas, I am still unable to figure it out for a couple reasons:

1) I don’t understand the syntax of the command in question enough to modify it so it will work with my particular application bundle. So I would really appreciate some help in this regard! This is the error I get when I run the thing, which also happens to show the directory structure I’m dealing with:

/Users/william/Programming/Xcode/Triangle Wars/build/Triangle Wars.app/Contents/MacOS/Triangle Wars can’t open library: libfmodex.dylib (No such file or directory, errno = 2)

libfmodex.dylib is in my build folder, which did allow it to work when run from within Xcode.

2) I don’t understand what the deal with the Shell Script Files build phase editor is. I see one field that is labeled “Shell:” with the text “/bin/sh” by default, and below that an unlabeled field. And below that a checkbox for “run only when installing”. I don’t know what any of that is.

Thanks for any help!

  • You must to post comments
Showing 13 results
Your Answer

Please first to submit.