[Solved] Disable CMD console

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

[Solved] Disable CMD console

Post by etreum79 »

hi, a question I can not see it anywhere,
how I can disable the CMD console that comes out when irrlicht start?

Greetings.
Last edited by etreum79 on Wed Mar 06, 2013 3:28 pm, edited 1 time in total.
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: Disable CMD console

Post by zerochen »

hi,

from the first example (the second part).

/*
To be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib.
We could set this option in the project settings, but to make it easy, we use a
pragma comment lib for VisualStudio. On Windows platforms, we have to get rid
of the console window, which pops up when starting a program with main(). This
is done by the second pragma. We could also use the WinMain method, though
losing platform independence then.
*/
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht_d.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

regards
zerochen
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Disable CMD console

Post by gerdb »

hi, if you use codeblocks ide

theres a dropdown menu in your build dialog where you can change from console app to gui app, then no console window will be opened when app starts.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Disable CMD console

Post by Mel »

This should be included in the FAQs as it is a question i see very often :D... Wait! it is already there!
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

Re: Disable CMD console

Post by etreum79 »

Hi, neither solutions work for me, I use VS 2012,

to put this in the header:

# ifdef _IRR_WINDOWS_
# pragma comment (lib, "Irrlicht.lib")
# pragma comment (linker, "/ subsystem: windows / ENTRY: mainCRTStartup")
# endif

the compiler says:

MSVCRT.lib (crtexe.obj): error LNK2001: unresolved external symbol _main
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

Re: Disable CMD console

Post by etreum79 »

Mel, if you will kindly tell me where because I swear I do not see it more than I look.

Un saludo granadino!.
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: Disable CMD console

Post by zerochen »

have you had a look a example 1? there they use it and it works.

the error msg says that you have not implemented a main function.
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

Re: Disable CMD console

Post by etreum79 »

if you look at the examples, but as you say it gives me error in the main function, the problem is that I have no major function, because what I'm doing is a dll
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: Disable CMD console

Post by zerochen »

a dll has not a window at all. so you cant hide it.

you have to add the code to your project and not to irrlicht.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Disable CMD console

Post by Mel »

http://irrlicht.sourceforge.net/forum/v ... =1&t=25751

There, look for the section

"● How do I compile an Irrlicht app without the console window with MSVC?"

But keeping in mind what you say, it seems VS2012 works other way. You should, in any case, use that pragma for the linker in the main program that calls your DLL, in an EXE not a DLL.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
charl3s7
Posts: 11
Joined: Sat Oct 03, 2009 3:17 am

Re: Disable CMD console

Post by charl3s7 »

#include <windows.h>

use

Code: Select all

 
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int nCmdShow) 
 
instead of

Code: Select all

 
int main() {
 
//Charles
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

Re: Disable CMD console

Post by etreum79 »

thank you very much for all the help, but these methods paraecen not work because I have not a int main () I work with

extern "C"
{
DLL_EXPORT DLL_APIENTRY example ()
{
device-> getTimer () -> setSpeed ​​(Speed​​);
}
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Disable CMD console

Post by hybrid »

Well, your answers are slightly off road now. If you compile your whole Irrlicht-related stuff into a DLL, your original statement 'when I start Irrlicht' makes no sense, as you cannot start a dll. So your cmd window would be created by the app that uses the dll. In case you really have an app, your statement that you have no 'main' or similar routine makes no sense, as no app (writenn in C++/C) could come without it. So what's the real point here?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Disable CMD console

Post by Mel »

He is creating a wrapper, in a DLL, for Irrlicht, so he can call irrlicht from other languages, like freebasic. Hence, there is really no "main" function. But seems that the console appears for some reason in the example application he has created to test his wrapper, and that was what he was trying to get rid of. But at any rate, this problem is solved (he has told me via PM), seems there is another way to kill the console from inside an application, using the function freeConsole().

http://msdn.microsoft.com/es-es/library ... 85%29.aspx
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Disable CMD console

Post by hybrid »

I doubt, though, that this window is created by the dll. Of course you can kill the console from the dll as well, but a better way is probably to compile the freebasic app with proper settings to avoid the console at all.
Post Reply