如何在没有终端窗口的情况下启动Mac应用程序 [英] How to launch a mac application without a terminal window

查看:224
本文介绍了如何在没有终端窗口的情况下启动Mac应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个开源c ++应用程序,并且在Windows和Linux上都可以正常工作,我终于有了Mac Mini(带有10.5.8),所以我刚刚在测试Mac版本.

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.

从终端窗口中运行我的应用程序并输入 ./appname 时,我的应用程序运行良好,但是如果相反,我从查找器中双击它,则它将首先打开一个终端窗口,然后运行我的应用程序,但似乎未将工作目录设置为正确的位置,因此我的应用程序死了.

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?

推荐答案

Mac二进制文件设置为使用终端"程序打开;除了制作一个完整的应用程序包,或者让另一个程序通过system或类似的程序启动它之外,没有其他解决办法.

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.

双击二进制文件时,将打开终端窗口,并以~作为当前目录.建议您首先在程序中使用chdir(2),以确保它在正确的目录中运行.

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.

这篇关于如何在没有终端窗口的情况下启动Mac应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆