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

Author Topic: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.  (Read 3044 times)

0 Members and 1 Guest are viewing this topic.

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« on: December 01, 2012, 04:11:29 am »
So my games been going perfectly recently.

Last night I decided to do a release build just to see what the FPS is like! So I compiled and got a 'The operation completed successfully, unhandled exception' error... I checked some forums and some people pointed it at the console window..

So I changed my release build from 'CONSOLE' subsystem to 'WINDOWS' to remove the console, and set 'main' as the entry point (had to do that for some reason?) - this got rid of the error!! However.. when I close my game now in release with this new no console window approach.. the game closes down, but it still lives in my processes.. as if its not being killed properly... also if i run in VS2010 the game closes, but its not actually shut down.. I have to actually hit the 'STOP' button.. whats going on?!

Also how do I know if I am linking static or dynamic..

Your my only hope guys I was enjoying myself so much :(

edit: Linked sfml-main.lib into the lib links and still getting error on exit linked to crtexe.c, this only happens when sfml-main is linked.. otherwise program closes sucessfully but doesnt actual end the process...wtf
« Last Edit: December 01, 2012, 05:06:57 am by Tally »
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #1 on: December 01, 2012, 08:45:53 am »
Please read this carefully, and then give use more details about your problem.

http://en.sfml-dev.org/forums/index.php?topic=5559.0
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
AW: Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #2 on: December 01, 2012, 09:13:54 am »
So I changed my release build from 'CONSOLE' subsystem to 'WINDOWS' to remove the console, and set 'main' as the entry point (had to do that for some reason?)
If you link against sfml-main you don't need to specify the entry point.

However.. when I close my game now in release with this new no console window approach.. the game closes down, but it still lives in my processes.. as if its not being killed properly... also if i run in VS2010 the game closes, but its not actually shut down.. I have to actually hit the 'STOP' button.. whats going on?!
Well closing the window doesn't automatically shutdown the application, that's why most of the game loops use: while(window.isOpen())
Also when run in VS, just press pause and look where your application is.

Debugging (which includes reading the call stack) is the most important task of a programmer, so get used to it. ;)

Also how do I know if I am linking static or dynamic..
sfml-MODULE(-d) = dynamic
sfml-MODULE-s(-d) = static
Also for dynamic linkage you need the SFML dlls for static you don't.

edit: Linked sfml-main.lib into the lib links and still getting error on exit linked to crtexe.c, this only happens when sfml-main is linked.. otherwise program closes sucessfully but doesnt actual end the process...wtf
Read the callstack & debug.

Also what Laurent said. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #3 on: December 01, 2012, 08:46:48 pm »
Right, after some debugging I have found what I think is the problem...

here is my 'main loop'

#include <SFML/Graphics.hpp>
#include "GameEngine.hpp"
#include "sGraphicsManager.h"

#include "IntroState.hpp"

#include <Box2D\Box2D.h>

//Include MemoryLeak Detector.
//#include <vld.h>
int main()
{
        GameEngine Game( "MPEngine Alpha 1.0", 1600, 900, 32, true);

        Game.run( Game.build<IntroState>( true ) );

        // main loop
        while( Game.running() )
        {
                Game.nextState();
                Game.update();
                Game.draw();
        }

        sGraphicsManager *Graphics = sGraphicsManager::Instance();
        Graphics->Release();

    return 0;
}
 

now if I remove the lines

sGraphicsManager *Graphics = sGraphicsManager::Instance();
Graphics->Release();
 

Release mode runs fine.. but why would this cause an error?

Graphics Release
void sGraphicsManager::Release()
{
        // Release single instance
        if(msGraphicsManagerInstance)
        {
                std::cout << "Cleaning up Graphics Instance" << std::endl;
                delete msGraphicsManagerInstance;
                msGraphicsManagerInstance = NULL;
                std::cout << msGraphicsManagerInstance << std::endl;
        }
}
 

and my destructor
sGraphicsManager::~sGraphicsManager(void)
{
        for (std::vector<sf::Texture*>::iterator deleter = mTextureList.begin(); deleter < mTextureList.end(); deleter++)
        {
                delete *deleter;
        }
}
 

now if I remove the texture deleting code inside the destuctor.. release runs fine

if I move the texture delete code out of the destructor and into the Release function the is has changed and is now;

Windows has triggered a breakpoint in Box2D_SFML_Test.exe.

This may be due to a corruption of the heap, which indicates a bug in Box2D_SFML_Test.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Box2D_SFML_Test.exe has focus.

The output window may have more diagnostic information.


.. and this ONLY happens in RELEASE compile
« Last Edit: December 01, 2012, 08:56:35 pm by Tally »
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #4 on: December 01, 2012, 09:22:59 pm »
The short answer and the one you should follow is: Don't use manual memory management (i.e. new/delete) and don't use global variables (i.e. singletons are also global variables)! ;)

For the longer answer which I don't want to go much further into, it probably has something to do with, that global objects do not have a clearly defined order to get created/destroyed, thus X might reference Y but Y gets destroyed before X thus causing a crash.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #5 on: December 01, 2012, 09:31:18 pm »
The short answer and the one you should follow is: Don't use manual memory management (i.e. new/delete) and don't use global variables (i.e. singletons are also global variables)! ;)

For the longer answer which I don't want to go much further into, it probably has something to do with, that global objects do not have a clearly defined order to get created/destroyed, thus X might reference Y but Y gets destroyed before X thus causing a crash.

Whats the best way of making the 'order' work ?
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #6 on: December 01, 2012, 09:47:02 pm »
Whats the best way of making the 'order' work ?
Don't use global variables (i.e. singletons are also global variables)! ;)
That's really the best way!

For the rest I don't know and I don't really want to know. ;D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #7 on: December 01, 2012, 10:30:57 pm »
Whats the best way of making the 'order' work ?
Don't use global variables (i.e. singletons are also global variables)! ;)
That's really the best way!

For the rest I don't know and I don't really want to know. ;D

Haha yeah well I guess I'll have to make a normal declaration of my graphics manager and just pass it by reference to everything.. which looks ugly  >:(

You would think this problem is due to that though yeah, not a broken DDL or anything wierd? haha

its definitely that texture delete line..
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
Re: Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« Reply #8 on: December 01, 2012, 10:42:18 pm »
I guess I'll have to make a normal declaration of my graphics manager and just pass it by reference to everything.. which looks ugly  >:(
Or refractor your code and use a better design, so not everything needs a reference to your graphics manager. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything