How to run a Mac application without a terminal window

I wrote an open source C ++ application and it works fine on Windows and Linux, I finally got the Mac Mini (from 10.5.8), so I just tested the Mac version.

My application works fine when it starts from the terminal window and types ./appname , but if instead I double-click on it from the search device, it will first open the termnial window and then launch my application, but it does not seem to set the working directory to the right place, so my application is dying.

How can I configure the application when it starts when I double-click on it, the terminal window does not open first, and how can I automatically set the current directory to the application location?

+6
c ++ user-interface terminal macos
source share
1 answer

Mac binaries are installed to open using the Terminal program; there is no way around this, except that you are making a complete application package or running another program through system or something like that.

When you double-click on a binary file, the terminal window opens with ~ as the current directory. I suggest you use chdir(2) in your program to make sure that it works in the correct directory if you need it first.

+4
source share

All Articles