views:

96

answers:

1

I've written an open-source c++ application and it works fine on Windows and Linux, I finally got a Mac Mini (with 10.5.8) so I've just been testing the Mac version.

My application works fine when running it from inside a terminal window and typing ./appname , but if instead I double click on it from the finder, then it opens a termnial window first and then runs my app but it doesn't seem to set the working directory to the correct location so my app dies.

How do I make my app so when it launches by being double clicked on it doesn't open a terminal window first and how can I have the current directory set to the apps location automatically?

+2  A: 

Mac binaries are set to be opened with the 'Terminal' program; there's no way around that, except by making a full application package, or have another program launch it via system or something like that.

When double-clicking on a binary, the terminal window opens with ~ as the current directory. I suggest you use chdir(2) in your program to ensure it is running in the right directory if you need it in the first place.

zneak
That worked! Thanks, now my app runs but the terminal window stays on top of my app's window. Do you know how to hide or close the terminal window?
KPexEA
@KPexEA: you can't have it both ways unfortunately - you either write a generic command-line tool or you write a proper Mac app with a GUI, with a bundle, .plist etc.
Paul R
@Paul R, I do want it to be a proper Mac app. Do you know of somewhere that documents how to make it into a proper app. I'm using a makefile to build it so if I can add "make bundle" to my makefile that packages it all up that would be best. It's a single exe, no seperate data files are needed.
KPexEA
@KPexEA: you can start with the info here: http://developer.apple.com/mac/library/documentation/corefoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Paul R