[英]How to launch a mac application without a terminal window
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. 我已经编写了一个开源的c ++应用程序,它在Windows和Linux上运行良好,我终于得到了Mac Mini(10.5.8),所以我刚刚测试了Mac版本。
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. 从终端窗口运行它并输入./appname时 ,我的应用程序工作正常,但如果我从查找器双击它,然后它首先打开一个termnial窗口然后运行我的应用程序,但它似乎没有设置工作目录到正确的位置,所以我的应用程序死了。
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? 如何通过双击启动我的应用程序,首先不打开终端窗口,如何将当前目录自动设置到应用程序位置?
Mac binaries are set to be opened with the 'Terminal' program; Mac二进制文件设置为使用“终端”程序打开; 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. 没有办法解决这个问题,除了制作一个完整的应用程序包,或者让另一个程序通过
system
或类似的方式启动它。
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. 我建议您在程序中使用
chdir(2)
,以确保它在正确的目录中运行,如果您首先需要它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.