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

Author Topic: [RESOLVED] segmentation fault with TcpListener in minimal code example  (Read 1933 times)

0 Members and 1 Guest are viewing this topic.

Cara Citrine

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
On Ubuntu 13.04 I compiled and successfully ran this code example:

https://github.com/SFML/SFML/wiki/Source%3A-Network-Chat-Example

...and got a segmentation fault very soon after the program began.

I isolated the problem down to the following:

Code: [Select]
#include <SFML/Network.hpp>

// when this is commented the segmentation fault goes away
// but when it is commented the program runs fine
//sf::TcpSocket socket;

int main()
{
sf::TcpListener listener;
listener.listen(5000);

return 0;
}
below is attached an image of what code::block's debugger output when I ran it.



(I normally just use the terminal via make and then ./name-of-program, but
code::blocks uses the same compiler and also gets the seg fault) in the
same place)

After this happened I completely removed SFML 2.0 and then built 2.1 from source
and got exactly the same issue.

I took the source code for 2.1 from http://www.sfml-dev.org/download.php

used cmake to build from source, then navigated to the output folder via the
terminal and did the usual make, sudo make install. 

The only odd thing I see when I make the source code is something about a
joystick shown below. I don't think it is relevant but worth mentioning.


I thought it might be my compiler potentially being outdated or something, but
when I used "dpkg --list | grep compiler" in terminal I got the below data. It looks like
it is up to date.



My makefile looks like this:
 
Code: [Select]
all:
g++ basicchat.cpp -o basicchat  -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network  -I/home/cara/Programming/Libraries/sfml2-build/include  -L /home/cara/Programming/Libraries/sfml2-build/lib
I tried using g++-4.7 instead of g++ and got the same result

Uninstalling once more and building from the github source did not change anything either.


However, I ran this on my windows partition and it worked fine. Might this have
something to do with how I either built, compiled, or linked?
Considering everything else in SFML has worked without any problems I am
seriously stumped. Google seems to suggest this isn't an issue for anyone
else, so I suspect it is some simple error if by the time one is in networking
it should be corrected.
« Last Edit: August 01, 2013, 08:36:23 pm by Cara Citrine »

Cara Citrine

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: segmentation fault with TcpListener in minimal code example
« Reply #1 on: August 01, 2013, 08:35:59 pm »
I did not figure out what the problem was, but I resolved the seg fault by installed Linux Mint. I did exactly the same compiling steps and so suspect I had something wrong between the libraries I had compiled SFML with to the way I was linking SFML.  I installed over Ubuntu so I cannot reproduce the issue.