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.
(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.phpused 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:
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.