SFML community forums

Help => General => Topic started by: zivkovic on May 18, 2012, 06:52:46 pm

Title: SFML gets terminated right away?
Post by: zivkovic on May 18, 2012, 06:52:46 pm
Okay, I'm new to this and firts thing I encountered is this. No mater what sample program I choose, it never runs as it should.

I'm using Eclipse C/C++ CDT and SFML 1.6. And for the compiler im using mingW.

Here are my settings in Eclipse C++ :

http://screensnapr.com/v/rt2Spy.png
http://screensnapr.com/v/oqPWxg.png
http://screensnapr.com/v/31mNQT.png

And here is the example i tried:

Source file:
http://screensnapr.com/v/8nv3tn.png

Header file:
http://screensnapr.com/v/0uoX3u.png

And after I run the program it immediatly does this:
http://screensnapr.com/v/drKR2b.png

Id appreciate any help. Thanks !
Title: Re: SMFL gets terminated right away?
Post by: Laurent on May 18, 2012, 06:57:55 pm
This program is not supposed to last long, it prints what it has to print to the console and returns.

So just make sure that the console stays open after the program returns so that you can see what's in it.
Title: Re: SMFL gets terminated right away?
Post by: zivkovic on May 18, 2012, 07:00:51 pm
I tried, this is what i tried:
http://screensnapr.com/v/V2of0J.png

When I ran that it did the exact same thing. If I commented the Clock stuff(http://screensnapr.com/v/sxZZr3.png), it ran as it should, but when its uncommented it doesent print anything. Even if it terminates it should leave it open for me to click/view output.

EDIT:

Here, the "console printout":

http://screensnapr.com/v/6iNCsW.png
Title: Re: SMFL gets terminated right away?
Post by: zivkovic on May 19, 2012, 11:13:48 pm
BUMP, I really need help with this.
Title: Re: SMFL gets terminated right away?
Post by: zivkovic on May 21, 2012, 11:24:23 pm
BUMP
Title: Re: SMFL gets terminated right away?
Post by: model76 on May 22, 2012, 01:14:15 am
This is a very common problem for new C++ programmers, and not related to SFML.

The first chapter in this tutorial (http://www.cprogramming.com/tutorial.html) has an explanation, as well as a solution. :)
Title: Re: SMFL gets terminated right away?
Post by: eXpl0it3r on May 22, 2012, 10:16:54 am
This is a very common problem for new C++ programmers, and not related to SFML.

Which means, read a book about C++ and learn the language before you want to do crazy stuff with SFML. ;)
Also bumping posts isn't really apprecieated...

If you need help instantly there are always IRC C++ channels on quakenet, freenode etc.
Title: Re: SFML gets terminated right away?
Post by: Laurent on May 22, 2012, 10:23:43 am
Quote
Also bumping posts isn't really apprecieated...
... by you ;)
I never officially said that bumps were disallowed or not appreciated. I'm personally ok with them as long as they are not overused.
Title: Re: SFML gets terminated right away?
Post by: zivkovic on May 22, 2012, 10:30:29 am
Im quite experienced with c and a bit less with c++, the problem is the program never actually starts, it builds and terminates instantly., i have "system("PAUSE"); in the code, so it should stop for me to press a key, but this option never appears.
Title: Re: SFML gets terminated right away?
Post by: Laurent on May 22, 2012, 10:34:09 am
Is the console activated in your project settings?

Can you reach the first line of main() if you execute the code step by step with the debugger?

Do you link to sfml-system only, or to other modules?
Title: Re: SFML gets terminated right away?
Post by: zivkovic on May 22, 2012, 02:31:46 pm
In Eclipse, console is always activated, im trying to run it thru the debugger, so that would be no. And im linking this three:

sfml-graphics-d
sfml-window-d
sfml-system-d

In the exact order as posted here. If u want u can try Eclipse C/C++ and add it yourself. You can get it here: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2 (http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2).
Title: Re: SFML gets terminated right away?
Post by: Laurent on May 22, 2012, 02:42:34 pm
Quote
im trying to run it thru the debugger, so that would be no
But the debugger doesn't run step by step by default, you must either do it explicitely or put a breakpoint on the first line.

Quote
sfml-graphics-d
sfml-window-d
sfml-system-d
Can you try to link to sfml-system only?
Title: Re: SFML gets terminated right away?
Post by: zivkovic on May 22, 2012, 04:26:27 pm
I had many brakepoints and use the built-in debugger, but still it just starts and terminates instantly.
Also as u suggested I only used sfml-system link, but that did not work aswell. If u want to u can see the situation on my computer, check ur PM for details.
Title: Re: SFML gets terminated right away?
Post by: Laurent on May 22, 2012, 04:35:14 pm
Have you tried to run the executable directly from a console (not from Eclipse)?

Are you sure that sfml-system.dll is found when you run the program (ie. it should be in the same directory as the executable)?
Title: Re: SFML gets terminated right away?
Post by: zivkovic on May 22, 2012, 04:57:57 pm
It is found but only if i start it thru eclipse. Now i copyed the sfml-system.dll to the folder where executable file is and ran it by double clicking on it. It worked, i tested on eclipse while the dll was in the same folder and again it worked. Soo is this the only option, to put the dll's into the same folder as executable, or can i load them from a different folder?
Title: Re: SFML gets terminated right away?
Post by: Laurent on May 22, 2012, 05:44:47 pm
You can put DLLs in any folder, as long as its path is added to the PATH environment variable. Standard paths such as C:\Windows\System32 or C:\Program Files are already in it.
Title: Re: SFML gets terminated right away?
Post by: model76 on May 22, 2012, 08:51:23 pm
It is found but only if i start it thru eclipse. Now i copyed the sfml-system.dll to the folder where executable file is and ran it by double clicking on it. It worked, i tested on eclipse while the dll was in the same folder and again it worked. Soo is this the only option, to put the dll's into the same folder as executable, or can i load them from a different folder?
That's strange. On my Windows computer I get an error that the application couldn't start because of a missing DLL, and it even names the DLL. It doesn't matter if I compile with the Microsoft compiler or MinGW.
Title: Re: SFML gets terminated right away?
Post by: zivkovic on May 23, 2012, 09:21:07 am
I know right. Thanks for all your help Laurent and others contributors.
Title: Re: SFML gets terminated right away?
Post by: ndj on March 27, 2014, 05:10:58 pm
Hi all.
For a first post in the sfml forums, I'm a little ashamed to exhume an old post... Well, It may help another lost user =)

If your executable instantly close (didn't run at all) it's probably cause it's missing some dlls. I guess your dlls are located near the exe cause windows can launch it properly. So why on earth eclipse can't find them ?

In fact you must configure the current directory of execution in the "Run/Run configuration..." pannels. The default one is probably not the one in which the dll (and exe) are located.

(http://i.imgur.com/6FYnchts.png) (http://imgur.com/6FYncht)