SFML community forums
Help => Network => Topic started by: Cara Citrine on July 30, 2013, 08:54:42 am
-
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:
#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.
(http://i.imgur.com/sSHfO6a.png)
(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.
(http://i.imgur.com/Aa8Yema.png)
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.
(http://i.imgur.com/A66cAhF.png)
My makefile looks like this:
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.
-
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.