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.
Related
I'm writing a Qt C++ program on Windows and it has registered a global shortcut Ctrl+j. Whenever the user press Ctrl+j, the program's UI will show up. When the active window is a Windows command line or a Windows explorer and the user presses Ctrl+j, I want to get the current directory of the Windows command line or a Windows explorer. Is that possible?
For Windows Explorer you can write a BHO and communicate with it from your application. BHO - Browser Helper Object - will load into Windows Explorer process and can access anything, e.g. windows handles, text in the textboxes etc. We've done this for Internet Explorer.
I am developing my Qt (c++) application on MacBook. However, the application might run in both Windows and Mac Systems.
Is there is a way to set platform independent application icon ?!
Setting application icons is already independent, Windows and OS X require different icon formats: http://doc.qt.io/qt-5/appicon.html
the application might run in both Windows and Mac Systems
Right, but not the same executable (binary), you'll compile two versions, one for Windows and one for Mac. Executable icon could be displayed by the OS (when aplication icon is shown on desktop, task bar...) before the application is actually started. So this icon cannot be set programmatically, it must be set at compilation time. And, you must refer to this post to know how to set the application icon for binaries on each different platform.
I use nativeprocess api in AIR to launch a c++ console app. The console app runs correctly but does not appear, but I want it to be visible and user be able to interact with it. How can I achieve that?
Instead of launching your executable directly, you'll need to launch your platform's terminal application (on Windows, that's CMD.exe, on OS-X it's Terminal.app, and on unix/linux it's xterm).
By default, the terminal application will run an interactive shell prompt, but you can use command-line arguments to tell it to execute any other program instead. In this case, you'll want to tell it to execute your C++ console application.
On Windows, this might look something like this:
CMD.exe /K C:\path\to\your\app.exe
on OS-X, it's a little more complicated. Here's a related S.O. post ( Running a command in a new Mac OS X 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.
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.
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.