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

Author Topic: Segmentation error with example code and Ubuntu  (Read 3635 times)

0 Members and 1 Guest are viewing this topic.

Orfby

  • Newbie
  • *
  • Posts: 31
    • View Profile
Segmentation error with example code and Ubuntu
« on: March 31, 2015, 12:29:33 pm »
When I tried to compile the example code (from here: http://www.sfml-dev.org/tutorials/2.2/start-linux.php),  the desired green circle appears for a short amount of time (less than a second usually), then the window closes and the terminal says Segmentation error (core dumping). On my previous OS (Windows 7) the example works perfectly, and doesn't close unexpectedly.

After running the Code::Blocks debugger, I picked out a piece of text that seems to be appropriate:
Program received signal SIGSEGV, Segmentation fault. In sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () (/home/ben/Documents/C++ Programming/Resources/SFML-2.2/lib/libsfml-graphics.so.2.2.0)

Specs and Versions:
Ubuntu Version: 14.04 (64 bit)
SFML Version: 2.2
IDE: Code::Blocks
« Last Edit: March 31, 2015, 01:10:21 pm by Orfby »

wetnightmares

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: Segmentation error with example code and Ubuntu
« Reply #1 on: March 31, 2015, 01:31:56 pm »
Install valgrind if you haven't already and run

sudo valgrind --track-origins=yes ./[i]your_program[/i]

and post the results

Orfby

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Segmentation error with example code and Ubuntu
« Reply #2 on: March 31, 2015, 01:52:28 pm »
From valgrind I got:
./SFML Test: error while loading shared libraries: libsfml-graphics.so.2.2.0: cannot open shared object file: No such file or directory
From that snippet, I'm assuming the library is named wrong, so the program can't find it.
EDIT: After looking around, None of the libraries appear to have any typos, so I'm not sure why it's complaining about not finding the file
« Last Edit: March 31, 2015, 01:56:05 pm by Orfby »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Segmentation error with example code and Ubuntu
« Reply #3 on: March 31, 2015, 01:58:58 pm »
Have you tried sudo ldconfig?

But segmentation fault and not found library are different issues. You are using the SFML 2.2 release, not a Git version, right?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Orfby

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Segmentation error with example code and Ubuntu
« Reply #4 on: March 31, 2015, 02:06:54 pm »
I just compiled and found that the not found libraries is a completely different issue, so the text from valgrind is incorrect, and yes I'm using the release over Git version.

Orfby

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Segmentation error with example code and Ubuntu
« Reply #5 on: March 31, 2015, 03:14:35 pm »
Correct valgrind (hopefully):
Process terminating with default action of signal 11 (SIGSEGV)
Bad permissions for mapped region at address 0x5A6
 at 0x5A6: ???
 by 0x400FEC8: _dl_signal_error (dl-error.c:125)
 by 0x400E9C2: dl_map_object_deps (dl-deps.c:698)
 by 0x400315C: dl_main (rtld.c:1742)
 by 0x4017564: _dl_sysdep_start (dl-sysdep.c:249)
 by 0x4004CF7: _dl_start (rtld.c:332)
 by 0x40012D7: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)

wetnightmares

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: Segmentation error with example code and Ubuntu
« Reply #6 on: March 31, 2015, 05:39:13 pm »
try running as super user?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Segmentation error with example code and Ubuntu
« Reply #7 on: March 31, 2015, 05:59:14 pm »
try running as super user?
I'm currious to know why you think that would change anything? Really currious.
A segfault means the program attempted to read or write memory outside its address space. Why would running as root change that?
I'm more currious to know if he really used the code from the tutorial verbatim or not as well as what compiler (and version) he used and also whether he has an old version of SFML installed from his distributions repositories that gets picked up at runtime. Output from ldd might be helpful.

Orfby

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Segmentation error with example code and Ubuntu
« Reply #8 on: March 31, 2015, 07:20:01 pm »
Although this may not be helpful to anyone else who might see this thread, I fixed it. I don't really know how though, all I did was remove, then redo all the build options and I guess I got it to work  8).

 

anything