SFML tutorial, again O_o

Pages: 12
closed account (y8h7M4Gy)
Hello... again, an SFML problem for me :(
what linkers do i need to compile the SFML tutorial "Using render windows", because it said i only need
i link the sfml-graphics library, but it says "Segmentation Fault" what other libraries do i need?

thanks in advance
Segmentation Fault is not a compile-time error. Check all your arrays for out-of-bounds problems and pointers for validity, as a Segmentation Fault occurs when you try to write to or read from a piece of memory that is write- or read-protected, respectively, inclusively.

-Albatross
Last edited on
closed account (y8h7M4Gy)
no cuz i tried thier source code and it still didnt work :(
If you don't believe me, read this:
http://en.wikipedia.org/wiki/Segmentation_fault

Not including a library usually doesn't result in said errors, rather linkage errors.

-Albatross
Last edited on
1. Post the code.
2. Specify what line in the code causes the problem.
As Albatross said, forgetting to link a library would not cause a segmentation fault, but a link error.
closed account (y8h7M4Gy)
i know what your talking about i am a pretty experienced SDL developer, but im saying i used their code and it still doesnt work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#include <SFML/Graphics.hpp>

int main ( int argc, char** argv ) {

	sf::RenderWindow App ( sf::VideoMode ( 800, 600, 32 ), "SFML Graphics" );
	sf::Event Event;
	sf::Clock Clock;

	while ( App.IsOpened () ) {

		while ( App.GetEvent ( Event ) ) {

			if ( Event.Type == sf::Event::Closed ) {

				App.Close ();

			}

			if ( Event.Type == sf::Event::KeyPressed ) {

				if ( Event.Key.Code == sf::Key::Escape ) {

					App.Close ();

				}

				if ( Event.Key.Code == sf::Key::F1 ) {

					sf::Image Screen = App.Capture ();
					Screen.SaveToFile ( "screenshot.jpg" );

				}

			}

		}

	App.Clear ( sf::Color ( 200, 0, 0 ) );
	App.Display ();

	}

	return EXIT_SUCCESS;

}


and it doesnt say what line of code it is

1
2
3
4

elijah@edward:~/C++/LearningSFML/8.Using render windows$ ./app
Segmentation fault
Do you have a debugger? If so, set breakpoints for every line (excluding empty lines), and step through it. That will get you the line.

As for me, I'm probably missing something obvious.

-Albatross
closed account (y8h7M4Gy)
no i just use the command line ( terminal ) and g++
but the thing is i took THEIR code that they said will work and it didnt
There is a possibility that you got an unstable version of SFML that still has a few bugs. What version are you using, and where did you get it from?

-Albatross
Last edited on
Works for me:
1
2
3
$ g++ sfml.cpp -lsfml-window -lsfml-graphics -lsfml-system
chris@chris-al:~$ ./a.out 
chris@chris-al:~$
Red screen, 800x600 px, window title is "SFML Graphics"


It must be your version of SFML.
I tested the code, compiles and runs fine for me too.
You don't even need to set any breakpoints, just run it with gdb. The callstack will tell you where the problem occured.
closed account (y8h7M4Gy)
Hmmm... yeah im using sfml 1.5 ... i hate the ubuntu synaptic package manager... should have know to download it directly lol
closed account (y8h7M4Gy)
if sfml 1.6 compatible with ubuntu?? cuz it still doesnt work.. ill try on arch
If any Linux distro is going to have the unstable version of SFML it's Arch...
closed account (y8h7M4Gy)
Umm.. arch is known to be the most up-to date distro of all
Yes, that's why.
The Arch Linux Wiki wrote:
If you have read, and agree with The Arch Way philosophy, embrace the 'do-it-yourself' approach and require or desire a simple, elegant, highly customizable, bleeding edge, general purpose GNU/Linux distribution, chances are you may like Arch.
Wikipedia wrote:
Bleeding edge is a term that refers to technology that is so new (and thus, presumably, not perfected) that the user is required to risk reductions in stability and productivity in order to use it.


Don't get me wrong; I'm using Arch right now: http://i49.tinypic.com/291mb7b.png

Umm.. arch is known to be the most up-to date distro of all

So you've reviewed every distro in existance to check if it's more or less up-to-date than Arch?
closed account (y8h7M4Gy)
no i obviously havent reviewed every distro, but the one i compiled the program on " ubuntu " i know that sometimes it takes weeks for something new to come into the software manager/package manager and ive read a few reviews that arch has a better package manager ( pacman )
Well, that depends on your definition of "better". pacman is simpler and faster and IMO it is better; but that doesn't mean that it is.

Also, no review can beat experience. Most people reviewing Linux distros install <distro> and then proceed to download and install 50 .iso files of other distros, stick them all on an emulator and then benchmark them (remember that <distro> is the host OS, running on real hardware, and therefore has a massive advantage). I'm not even making this up; I've actually read such a review (IIRC it was Ubuntu vs. FreeBSD).
closed account (y8h7M4Gy)
blah cross out the word better, change it to " more up to date "

true, i installed arch on vbox, i like it a lot, the only reason i dont put it on my accual computer is that is would be a pain reinstalling everything and also i need to back-up all my files
Backups are for lesser mortals.
(2 days later)
</data>
Pages: 12