vendredi 28 octobre 2016

SFML undefined reference to `sf::TcpSocket::TcpSocket()'

I am trying to compile SFML simple code:

#include <iostream>
#include <string>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>

using namespace std;

int main(int argc, char* argv[])
{

    sf::TcpSocket socket;
    sf::Socket::Status status = socket.connect("127.0.0.1", 6000);
    if (status != sf::Socket::Done)
    {
        // error...
    }
    return 0;
}

All libs and dependencies are installed:

sudo apt-get install libsfml-dev
sudo apt-get build-dep libsfml

I am using two methods:

g++ -c main.cpp
g++ -o main main.o -std=c++11 -lsfml-graphics -lsfml-window -lsfml-system

g++ -c main.cpp -I/home/x64joxer/SFML-2.4.0/include
g++ -o main main.o -L/home/x64joxer/SFML-2.4.0/lib -std=c++11 -lsfml-graphics -lsfml-window -lsfml-system

But I still have the same problem:

main.o: In function `main':
main.cpp:(.text+0x27): undefined reference to `sf::TcpSocket::TcpSocket()'
main.cpp:(.text+0x38): undefined reference to `sf::IpAddress::IpAddress(char const*)'
main.cpp:(.text+0x54): undefined reference to `sf::TcpSocket::connect(sf::IpAddress const&, unsigned short, sf::Time)'
main.o: In function `sf::TcpSocket::~TcpSocket()':
main.cpp:(.text._ZN2sf9TcpSocketD2Ev[_ZN2sf9TcpSocketD5Ev]+0x30): undefined reference to `sf::Socket::~Socket()'
main.cpp:(.text._ZN2sf9TcpSocketD2Ev[_ZN2sf9TcpSocketD5Ev]+0x56): undefined reference to `sf::Socket::~Socket()'
main.o:(.rodata._ZTIN2sf9TcpSocketE[_ZTIN2sf9TcpSocketE]+0x10): undefined reference to `typeinfo for sf::Socket'
collect2: error: ld returned 1 exit status

I read many tutorials and topics at the forum but I still do not know how too fix it. My system is Kubntu 15. Can anyone know how to fix it?

Aucun commentaire:

Enregistrer un commentaire