Mono GUI Runtime How to hide the console window - xamarin

I have a Mono Winforms project compiled with Xamarin Studio. When I run from XS, it does not show a console windows. However, after I bundle the package on the Mac( using mkbundle and pkgbuild) and then install it, a bash shell is shown when I execute the program. When I exit the program, the shell remains open with a final message "Process completed". I then have to close the shell window.
I would like to be able to execute the application and not show the console window. It would also be acceptable if the shell window would close by itself when the application exits.
I tried and added this tag to my csproj but no good:
WinExe
I saw another post which stated to use a compiler switch to specify the target to be WinExe. However, I do not see anywhere in XS to add custom compiler switches. ( I think the switch was /target:WinExe).
Anyone have any workaround that these have used for this case?
Thanks in advance.

Project options / Build / General / Code Generation / Compile Target
Executable = /target:exe
Library = /target:library
Executable with GUI = /target:winexe
Module = /target:module

Related

Run termbox-go app in GoLand's console

I want to create a Go app with a console UI using the termui library (which is built on top of the termbox-go library). I can build the app and run it from the command line, but it will not start inside the GoLand IDE (2018.1.3) on Windows 10.
It fails during the termbox-go init when calling syscall.Syscall with SetConsoleScreenBufferSize parameter. The size for the screen buffer is 80x25. Error message is just "The parameter is incorrect."
How can I debug a termbox-go app in the GoLand or other IDE?
I think the way to solve this is to build your executable with Go 1.10 or newer, compile it with the following flags: -gcflags="all=-N -l" (these are very important and will allow the debugger to work a lot better, and then use the Run | Attach to Local Process... option from GoLand and attach to the local process.
I'll see if I can replicate the bug and update this accordingly.

How to debug code running from terminal in pycharm

I am running my code in Pycharm from Terminal. Is it possible to debug the code and put breakpoints inside the code during a run from terminal?
I don't know anyway to do this through the terminal, but the way I currently do it is:
Run > Edit Configurations > Add new configuration (the green + button)
Choose Python
Fill out Script path, Parameters, and other configuration fields.
Debug the newly added configuration. (Run > Debug...)
With the right configuration the result should be the same as running the script in a terminal.
I find the above process a little tedious. A PEP 553 breakpoint() might be nicer. It requires Python 3.7 and is not implemented yet. See the related issue.
Even if the program is started outside of PyCharm, we can attach PyCharm debugger to it.
Go to Run -> Attach to process.
This will show a list of python process that are currently running on the system. Select the appropriate process from it.
Now PyCharm debugger is connected to that process. We can add breakpoints and debug it.
There is a way using python console.
To run it: Tools -> python console .. or you can find it at the bottom of the IDE.
Then press on 'Attach debugger' line in the following picture:
Add a breakpoint in your code and then pass the file name to the cosole, like: %run my_file.py

force TideSDK debug console window to stay open on windows

I'm trying to debug a HTML5/javascript application that uses the TideSDK (1.2.0RC4). I can run the build script and create an executable and start it with <appname>.exe --debug. The executable starts and opens a separate console window with log output, than exits with an error code and closes the console window. I've got no idea what went wrong because I can't see the log output. How do I force the window that contains the log output to stay open? I dimly remembered cmd /k ... but that doesn't work. Anyone any pointers?
Checkout TideSDK 1.3.1-beta available for download at http://tidesdk.org
The earlier version is not supported.

Set icon without *.pro

I have an application written with Qt (I use VS + Integrator). Need to set an icon for it. I read "Setting the Application Icon" tutorial, but i can't use this method because I have no *.pro file. Googled for an hour and found no solution :( Any suggestions?
Create an application which is simply an empty QMainWindow (or some other widget) and then create a qmake project for it. You can typically do this with:
qmake -project
Then modify the qmake file per the Setting the Application Icon tutorial and rebuild your Makefile by running qmake.
Now examine the commands that are being executed and emulate that process on your build system.
These instructions might work if you're running Visual Studio.

Why does my Qt 4.5 app open a console window under Windows?

I've been playing around with Qt Creator 4.5 under Linux. My application builds just fine under Linux, but if I build in Windows, the app always opens a console window at startup.
Can I stop it doing that?
I'm building using the default MinGW setup, perhaps that is related. If need be I can build with Visual Studio, but I'd like to understand what is happening first...
Edit: I just created a simple test GUI app with Qt Creator under Windows and it didn't exhibit this behaviour. Either this behaviour has occurred because of the way the project was created under linux, or there is something my app does which causes the console window to appear. Will post details when I diagnose it in case it helps someone else.
For those who have this issue using CMake under Windows (see Amoo's comment), here's a solution here.
In short, you need to add WIN32 to your add_executable() statements:
add_executable(GuiApplication WIN32 src/main.cpp)
For further details, see the CMake documentation on add_executable and WIN32_EXECUTABLE.
The short answer is that including the Qt testlib causes the console to appear. Removing it makes it go away.
To explain further, if your .pro file adds testlib to QT, e.g.
QT += sql \
webkit \
network \
testlib
then the final link step is carried out with a line like this
g++ -enable-stdcall-fixup
-Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc
-mthreads
-Wl
-Wl,-subsystem,console
-o debug\MyApp.exe object_script.MyApp.Debug
-L"c:\Qt\2009.01\qt\lib"
-lglu32 -lgdi32 -luser32 -lQtWebKitd4 -lQtTestd4
-lQtSqld4 -lQtGuid4 -lQtNetworkd4 -lQtCored
We've wound up using the console subsystem! I presume using testlib forces this to happen so that the test output has somewhere to go.
If we now edit the .pro file and remove the reference to testlib and rebuild, we get a link step like this
g++ -enable-stdcall-fixup
-Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc
-mthreads
-Wl
-Wl,-subsystem,windows
-o debug\Ammotin.exe object_script.Ammotin.Debug
-L"c:\Qt\2009.01\qt\lib"
-lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lQtWebKitd4
-lQtSqld4 -lQtGuid4 -lQtNetworkd4 -lQtCored4
Yay! subsystem is windows, no more console window.
I think that this is not a solution for this specific answer (besides it is 4 years later),
but I think that many people landing in this thread will be looking for this setting:
Projects > Build and Run > Run Settings > Run > [x] Run in terminal
De-select it and run your GUI from QtCreator without an extra Terminal window. Terminal output will be then embedded in the IDE.
You will want to make sure the -mwindows switch is provided.
Edit:
alternatively, you can go into your makefile and add this to your linker flags:
-Wl,-subsystem,windows
Make sure your .pro file doesn't add console to the variable CONFIG. You can do this by adding
CONFIG -= console
somewhere at the end of your .pro file. If CONFIG contains console a window pops up every time you start the program, and this is also used when printing debug output. Thus, adding console can be useful when debugging a program. Otherwise you'd need to use tools like DebugView to show the output of the qDebug() calls.
I use cmake instead of qmake. I used set(CMAKE_CXX_FLAGS "-mwindows")
seems as though
QMAKE_CXXFLAGS +=-mwindows
in your .pro file would do the same.
Sounds like your linker settings are set for a console app. You could try setting the linker to use the /subsystem:windows option. The option for console applications is /subsystem:console. If you build your project in Visual Studio, create a Win32 Project. Don't create a Win32 Console App. The option under Visual Studio for setting the subsystem is under Project Settings->Linker->System->SubSystem. Select Windows(/subsystem:windows).
I took a look into how to do this with MinGW/gcc. The online docs for gcc shows the different options for Windows targets. Like other have stated, the option you are looking for is -mwindows. The option -mwindows creates a windowed app. It seems like your current setting is -mconsole. The option -mconsole produces a console app. This is a linker option. I'm not familiar with Qt Creator but I'm guessing it has a similar way to view project settings like Visual Studio has.
Go to: Projects --> Run and uncheck Run in terminal checkbox
By default the linker assumes you want a console application.
The fix is to add "-mwindows" to your compiler's argument list, and this will also invisibly add the required libraries (-lkernel32, -lgdi32, etc.). You'll probably need to change from main() to WinMain() as the entry point.
RE: your Edit: the Qt build system uses "spec" files to add variables, you can find them in $QTDIR/qt/mkspecs. When you create a new Windows app in QCreator, it sets the default spec to "win32-g++", which automatically sets the correct variables (windows app, linker flags, etc.).
When you made the project under Linux, it used another spec and that caused your issue. You can see the current spec in the "yourproject.pro.user" file.
Qt/2009.05/qt/mkspecs/win32-g++
edit file qmake.conf
modify line
QMAKE_LFLAGS_CONSOLE = -Wl,-subsyetem,console
to
QMAKE_LFLAGS_CONSOLE = -Wl,-subsyetem,windows
and modify your ???.pro file (example add new line or space)
and compiling
it`s working ok

Resources