How to launch a mac application without a terminal window - c++

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?

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.

Related

SFML window application remove console

For an application, while I make the final application, How could I remove the terminal window for the final application on MacOS or Linux.
I find the key point, that is in macos we should build a app file, which should consist of Resources folder、MACOS、PkgInfo、Info.plist files, then when I just click the packaged file, the application could just show the GUI window.

How to prevent tkinter window from closing when I close Windows command console

I open my CMD console to run my main.exe. I type:
python main.exe
My main.exe is a small window written with Tkinter. When I close the command console, my program ends and the window closes. I would like to terminate the console without terminating the program.
edit:
Saving my file as a .pyw doesn't work. Also, the console doesn't just magically appear. I'm not running the script in an IDE. I'm opening it with DOS. The program just closes when I close the cmd console.
Run it with pythonw.exe.
The reason for this is that on Windows executables have a flag to tell the operating system they use a console or not. python.exe expects a console and if if is not already attached to one, it wll create one. pythonw.exe is linked with the GUI flag and does not create a console and if run from a console window will detach from that console.
This is why Tk uses wish.exe on Windows and not tclsh.exe with 'package require Tk' which would be ok on Unix but gives an unwanted console window on Windows.
If changing the extension to .pyw does not help check the program associated with this extension. For instance, on my Windows machine with Python 3.4 I have:
C:\opt\Python>assoc .pyw
.pyw=Python.NoConFile
C:\opt\Python>ftype Python.NoConFile
Python.NoConFile="C:\Windows\pyw.exe" "%1" %*
And pyw.exe does not attach to my console when run.

Run Mac application of C++ and Qt on another Mac

I am trying run a simple C++ with QT application on another mac. I am trying to avoid having to install Qt on the other mac. This application was created in Xcode with cmake.
Two notes: my application (for some reason) does not create an .app file. It just creates a file with the name of my project (and no extension). I can run this file by double clicking, but still, it is not an .app. Does this matter?
Another thing, I am linking my application to static libraries of Qt. From what I understand, this should allow to run the application even if Qt is not installed, right? The result of running my application on the other mac is simply a terminal window that says: Instruction unknown.

How to hide console window in Mac OS (gcc compiler)?

I write an application with Code::Blocks IDE in Mac OS (C++ application).
CodeBlocks uses gcc to compile the source code.
When I double click on the output of the project (executable binary file), my application executes correctly but a console application shown. My application is a background application without any reading or writing to console, and I add it to startup items. I don't want when I logon, a balnk console (of my application) shown. I want to hide the console window.
How to hide console window in Mac OS with gcc compiler?
It sounds like what you are developing is a daemon (background process that is launched when a user account is logged on, or system is launched). OS X uses launchd and launchctl to manage daemons, so you'll need to set up the proper plist entry in either the /System/Library/LaunchAgents (to launch during system boot) or ~/Library/LaunchAgents (to launch when a user logs in) directory, and register it with launchctl.

Code::Blocks: How to run within IDE?

When I ask CodeBlocks to run my built application it spawns a terminal window and runs the application within that window. How do I instead get it to run within the IDE's log window?
This is something that is not implemented in Code::Blocks as such.
Target executables are either run directly from the IDE (no console), or via the consolerunner program which calls whatever terminal is appropriate (e.g. cmd under Windows, xterm under Linux) and optionally prompts for a key once the process has exited. Which one it is (terminal or no terminal) depends on the "Type" field in the project's Properties window ("Build Targets" tab).
However, if you absolutely want, you can get the effect of running in the log window indirectly by executing your program as post-build step. In that case, your program's stdout and stderr will both be displayed in the build log tab.