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

Author Topic: SFML2 SegFaults on Clear  (Read 5360 times)

0 Members and 3 Guests are viewing this topic.

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« on: September 11, 2011, 04:02:59 am »
Greetings

  I'm having an issue with running SFML apps.
  They compile with no problem, but when I run them, it segFaults on window.Clear();

main.cpp
Code: [Select]

#include <SFML/Graphics.hpp>

int main() {

// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
 
// Start the game loop
while (window.IsOpened()) {

// Process events
sf::Event event;

while (window.PollEvent(event))  {

// Close window : exit
if (event.Type == sf::Event::Closed) {

window.Close();

}

}

// Clear screen
window.Clear();

// Update the window
window.Display();

}

return EXIT_SUCCESS;

}


and to compile i use

g++ -g -o main main.cpp -lGL -lGLU -lsfml-system -lsfml-window -lsfml-graphics && ./main

Haikarainen

  • Guest
Re: SFML2 SegFaults on Clear
« Reply #1 on: September 11, 2011, 06:14:29 am »
This is weird, remember having the same problem on 1.6 running linux debian 5 , dont remember any solution though.

Can you get the stack trace with sfml-d debugging symbols as well?

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #2 on: September 11, 2011, 02:12:51 pm »
Ok, here is my gdb output.

Code: [Select]

(gdb) run
Starting program: /home/elijah/cplusplus/test/main
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff728b69c in sf::RenderTarget::Clear(sf::Color const&) () from /usr/lib/libsfml-graphics.so.2
(gdb) bt
#0  0x00007ffff728b69c in sf::RenderTarget::Clear(sf::Color const&) () from /usr/lib/libsfml-graphics.so.2
#1  0x0000000000400e02 in main () at main.cpp:26
(gdb)

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #3 on: September 13, 2011, 12:55:44 am »
bump

Haikarainen

  • Guest
SFML2 SegFaults on Clear
« Reply #4 on: September 13, 2011, 01:17:18 am »
Have you tried window.Clear(sf::Color(254,254,254,254)); ?

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #5 on: September 13, 2011, 02:36:32 am »
No dice. Still segments

coolhome

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
SFML2 SegFaults on Clear
« Reply #6 on: September 13, 2011, 03:24:32 am »
Just taking a shot in the dark here but what if you tried.

g++ -g -o main main.cpp -lGL -lGLU -lsfml-graphics -lsfml-window -lsfml-system && ./main

I think the order of the linking matters.

p.s. I'm a noob with G++
CoderZilla - Everything Programming

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #7 on: September 13, 2011, 04:48:20 am »
Still no dice :S Laurent!! :P

Haikarainen

  • Guest
SFML2 SegFaults on Clear
« Reply #8 on: September 13, 2011, 04:55:53 am »
Try

Code: [Select]
sf::RenderWindow* window = new sf::RenderWindow(sf::VideoMode(800,600,32), "bleh");

instead, and make sure the rest of the code handles window like a pointer. Then do:

Code: [Select]
std::cout << window;

and tell us what it says

Haikarainen

  • Guest
SFML2 SegFaults on Clear
« Reply #9 on: September 13, 2011, 05:00:54 am »
Btw, other known errors for this:
linking releaselibs to debug target, or vice versa
dependency problems - try rebuilding sfml all from scratch

Example: http://www.sfml-dev.org/forum/viewtopic.php?p=34143&sid=58f2a02ab20abf78b56b173439f4db23

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #10 on: September 13, 2011, 02:21:14 pm »
It just gives a differant hex address every time

Code: [Select]

$ g++ -g -o main main.cpp -lGL -lGLU -lsfml-graphics -lsfml-window -lsfml-system && ./main
0x104ab30
$ g++ -g -o main main.cpp -lGL -lGLU -lsfml-graphics -lsfml-window -lsfml-system && ./main
0x24cbb30
$ g++ -g -o main main.cpp -lGL -lGLU -lsfml-graphics -lsfml-window -lsfml-system && ./main
0x176eb30
$ g++ -g -o main main.cpp -lGL -lGLU -lsfml-graphics -lsfml-window -lsfml-system && ./main
0x838b30

Haikarainen

  • Guest
SFML2 SegFaults on Clear
« Reply #11 on: September 13, 2011, 04:14:05 pm »
Quote from: "strongdrink"
It just gives a differant hex address every time


Allright, how about the second thing i posted about? My bat-sense tells me its that.

Either you link the wrong libraries to the wrong target (debug to release or vice versa)

OR

You mix library files, like link 2.0 but have 1.6 headers, or vice versa.

My tip: Remove ALL sfml files, download new files, try it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2 SegFaults on Clear
« Reply #12 on: September 13, 2011, 09:48:11 pm »
Have you tried to upgrade/change your graphics drivers? Does glxgear run without any problem?
Laurent Gomila - SFML developer

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #13 on: September 18, 2011, 11:19:07 pm »
Yes, glxgears runs fine.

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
SFML2 SegFaults on Clear
« Reply #14 on: September 19, 2011, 12:04:40 am »
Ok, I compiled from source and its all good...

KTHXBYE!

 

anything