Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Removing the little console in the background?  (Read 4973 times)

0 Members and 1 Guest are viewing this topic.

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Removing the little console in the background?
« on: July 17, 2014, 09:39:51 pm »
I don't like the little console in the back of my windows, I'm using Code::Blocks.
I already changed it from console to GUI application, and my friend also told me to link "-mwindows".
 I tried that but it still didn't go away.
Can someome please help me?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Removing the little console in the background?
« Reply #1 on: July 17, 2014, 09:59:08 pm »
You need to link the 'sfml-main' library to keep "main()" (rather than WinMain()) as the (portable) entry point while building as a Windows application on Windows (rather than a console app) and get rid of the console window.
More details in the vc tutorial.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #2 on: July 18, 2014, 03:55:17 pm »
Try adding this before main():
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Removing the little console in the background?
« Reply #3 on: July 18, 2014, 07:59:41 pm »
Try adding this before main():
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

No, no, no... please don't suggest stuff like this. Adding platform specific compiler/linker settings into code is very bad practice and is not the way to solve this issue.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #4 on: July 18, 2014, 10:12:27 pm »
Please don't suggest stuff like this
Ok ok ok. So sorry! I sometimes use it when compiling; it's simpler than going through compiler settings. It's also useful to see what it will look when finished (as a temporary test). That said, I rarely compile finished code so forgive me for suggesting the wrong thing.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Removing the little console in the background?
« Reply #5 on: July 18, 2014, 10:32:33 pm »
... it's simpler than going through compiler settings. It's also useful to see what it will look when finished (as a temporary test)...
If changing something as simple as what libraries you link against is a hassle, then pardon me for saying that you are doing it wrong.
How the build is done should be managed by a proper build system like SCons, qmake or plain old make or similar. If changing linked libraries is anything more than editing a single line in a plain-text build script (which is just as simple as (if not simpler than)) putting platform/compiler specific pragmas into source files, then you are doing it wrong.

Just as an example; for my current project I use SCons and changing what libraries I link against is just a matter of opening my SConstruct file in my favorite editor and editing a single line:
env.Append(LIBS = ['sfml-window', 'sfml-system'])
- simple as that (and yes, you can use SCons on Windows with Visual Studio).

By the way, what do you mean by "It's also useful to see what it will look when finished (as a temporary test)"? That bit didn't make sense for me at all.
« Last Edit: July 18, 2014, 10:34:49 pm by Jesper Juhl »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #6 on: July 18, 2014, 10:55:24 pm »
I said it was a temporary test. I meant that it's easy to throw in a simple line of code to just experience what it would be like without actually preparing it for final build. That can include showing it to someone.

If "doing it wrong" means that I use a line of code for my own, personal use because it's quicker than getting more software or using compiler settings (which seem bugged as many options move out of view after a few seconds and require the options to be re-opened - which is a hassle), then I'm okay with doing it wrong for now, especially since I'm not actually aiming built code at anyone else.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Removing the little console in the background?
« Reply #7 on: July 18, 2014, 11:03:46 pm »
If "doing it wrong" means that I use a line of code for my own, personal use because it's quicker
My point is that it should not be quicker. And if it is that's an indication that you've got stuff set up in a sub-optimal way.

... than getting more software or using compiler settings (which seem bugged as many options move out of view after a few seconds and require the options to be re-opened - which is a hassle)
Sounds like you are using an IDE and believe that changing settings in there (by clickity-clicking etc) and doing your build in there (probably more mousing around and click) is the only way to do it. I just wanted to tell you that "It's not"!  Actually, in my opinion, it's a fairly inefficient and poor way of doing things - which was sort of the point of my earlier comment.

Edit: remember, the IDE is not the compiler and the GUI it presents is not the only way to build things - better ways exist - especially once you want to automate stuff and/or build for multiple platforms.
« Last Edit: July 18, 2014, 11:08:10 pm by Jesper Juhl »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #8 on: July 18, 2014, 11:30:57 pm »
It's quicker because I can type quickly, it's simple, and I already have the code open in the editor. Saying that, you're right; I should probably be doing it elsewhere rather than using the options menu graphically in an IDE, but I'm new to using an IDE and still getting used to it so I don't think I could learn even more ways.

Also, as I mentioned earlier, I very rarely fully build anything myself - I struggle with building - but that's okay as my intention is not to build software but to have fun with coding. I generally don't mind a console window being there when I run an application since it's useful for outputting stuff :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Removing the little console in the background?
« Reply #9 on: July 19, 2014, 09:40:35 am »
I linked sfml-main and also tried
Code: [Select]
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
Still didn't work.
I'm doing
Code: [Select]
int main()
{
      //code;
}

Doodlemeat

  • Guest
« Last Edit: July 19, 2014, 03:25:12 pm by Doodlemeat »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #11 on: July 19, 2014, 03:23:31 pm »
Don't use the code I supplied. It was incorrect of me to suggest it.
It turns out that it's even "wronger" of me. After reading Jesper's reply, I thought you were using VS; I completely missed that you were using Code::Blocks!  :o

Anyway, according to this thread in the Code::Blocks forum, the solution is to:
Quote
change the application type from "console" to "GUI application" in the target options (project properties -> tab "build targets").
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Removing the little console in the background?
« Reply #12 on: July 20, 2014, 08:50:38 am »
Don't use the code I supplied. It was incorrect of me to suggest it.
It turns out that it's even "wronger" of me. After reading Jesper's reply, I thought you were using VS; I completely missed that you were using Code::Blocks!  :o

Anyway, according to this thread in the Code::Blocks forum, the solution is to:
Quote
change the application type from "console" to "GUI application" in the target options (project properties -> tab "build targets").
I'm' starting to believe that you didn't read my original post.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Removing the little console in the background?
« Reply #13 on: July 20, 2014, 12:20:33 pm »
I would double-check that you changed the setting for both Debug and Release mode.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Removing the little console in the background?
« Reply #14 on: July 20, 2014, 06:21:56 pm »
I'm' starting to believe that you didn't read my original post.
I did, I did! I'm unaware if there are more places to specify that's it's GUI in Code::Blocks so I thought I'd post the specific area that they suggest in case you didn't use that area. If you did exactly that already, you don't have to try it again  ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*