SFML community forums

Help => General => Topic started by: Gerald Bates on June 14, 2024, 01:20:05 pm

Title: [SOLVED] Console visibility
Post by: Gerald Bates on June 14, 2024, 01:20:05 pm
Hello everyone.  I have a quick question about the console window being shown in both debug and release.  Am I right in thinking that if I create an application and supply all the windows skeleton code and use WinMain(...), I can leave the debug as subsystem console and release as windows in visual studio? That way I only get a console for debug builds?
Title: Re: Console visibility
Post by: eXpl0it3r on June 14, 2024, 01:31:55 pm
Yes, that should work.

If you use sfml-main, you even don't have to use WinMain yourself, but you can link it in release and not in debug
Title: Re: Console visibility
Post by: Gerald Bates on June 14, 2024, 02:22:07 pm
Thankyou eXpl0it3r, I did not know that.  And it works, no need for winMain().  Now I have a console in debug build but not in release.

Just one annoying issue left in visual studio.  In debug build I get loads of errors like this one:

warning LNK4099: PDB '' was not found with 'sfml-graphics-s-d.lib(BlendMode.obj)

Is this because I am using a different version of VS than what you built the binaries with?  How can I stop these warnings?
Title: Re: Console visibility
Post by: eXpl0it3r on June 14, 2024, 02:29:52 pm
It complains that it can't find match PDB files, which would contain debug symbols for the given library.
We don't ship PDB files with the pre-build binaries.
You can either ignore the warning or build SFML from source and then make sure to also copy over the PDB files.
Title: Re: Console visibility
Post by: Gerald Bates on June 14, 2024, 05:21:04 pm
I will deal with PDB issue shortly.  I have installed cmake and compiled sfml from source, have static release and debug now.  Setup my project and tried to build but have errors?  It's the usual test program with a green circle in a window.  Errors are:

error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'sf::VideoMode'
error C2665: 'sf::RenderWindow::RenderWindow': no overloaded function could convert all the argument types
error C2660: 'sf::WindowBase::pollEvent': function does not take 1 arguments
error C2039: 'type': is not a member of 'sf::Event'

Any ideas what's going on?
Title: Re: Console visibility
Post by: Gerald Bates on June 14, 2024, 05:52:57 pm
I have had a thought.  Why don't I revert to using the pre-built binaries and copy over the pdb files from my build.  Would that work?
Title: Re: Console visibility
Post by: eXpl0it3r on June 14, 2024, 08:08:44 pm
You most likely built from master, which is the work-in-progress SFML 3 version.

You'd want to build from either the 2.6.x branch or the specific git tag.

I have had a thought.  Why don't I revert to using the pre-built binaries and copy over the pdb files from my build.  Would that work?
No, that wouldn't work.
Title: Re: Console visibility
Post by: Gerald Bates on June 14, 2024, 09:06:55 pm
Yes I built from master!  eXpl0it3r You are seriously good and I appreciate your help.  Will keep progressing and use the branch you suggested.  I am a beginner at this.
Title: Re: Console visibility
Post by: eXpl0it3r on June 14, 2024, 10:35:32 pm
All the best on your journey!  :)
Title: Re: Console visibility
Post by: Gerald Bates on June 15, 2024, 01:48:06 pm
Managed to download correct SFML version and run CMAKE to build static debug/release versions.  The typical test example (green circle) works.  I am also able to change whether I want to see the console in either debug or release versions without errors, so debug has a console and release doesn't.  I don't get PDB errors anymore either.

Thanks  eXpl0it3r for all your help, appreciated.
Title: Re: [SOLVED] Console visibility
Post by: eXpl0it3r on June 15, 2024, 10:23:25 pm
That's great to hear!

No problem :)