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

Author Topic: undefined reference to `DoServerTCP(unsigned short)'  (Read 2244 times)

0 Members and 1 Guest are viewing this topic.

TobiasSmollett

  • Newbie
  • *
  • Posts: 3
    • View Profile
undefined reference to `DoServerTCP(unsigned short)'
« on: July 18, 2012, 06:13:12 pm »
Hi there,
I'm new here so forgive my ignorance...
I'm trying to run this code ion codeblocks:
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <iostream>
#include <SFML/Network.hpp>

////////////////////////////////////////////////////////////
// Function prototypes
// (I'm too lazy to put them into separate headers...)
////////////////////////////////////////////////////////////
void DoClientTCP(unsigned short Port);
void DoClientUDP(unsigned short Port);
void DoServerTCP(unsigned short Port);
void DoServerUDP(unsigned short Port);


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Choose a random port for opening sockets (ports < 1024 are reserved)
    const unsigned short Port = 2435;

    // TCP or UDP ?
    char Protocol;
    std::cout << "Do you want to use TCP ('t') or UDP ('u') ? ";
    std::cin  >> Protocol;

    // Client or server ?
    char Who;
    std::cout << "Do you want to be a server ('s') or a client ('c') ? ";
    std::cin  >> Who;

    if (Who == 's')
    {
        // Run as a server
        if (Protocol == 't')
            DoServerTCP(Port);
        else
            DoServerUDP(Port);
    }
    else
    {
        // Run as a client
        if (Protocol == 't')
            DoClientTCP(Port);
        else
            DoClientUDP(Port);
    }

    // Wait until the user presses 'enter' key
    std::cout << "Press enter to exit..." << std::endl;
    std::cin.ignore(10000, '\n');
    std::cin.ignore(10000, '\n');

    return 0;
}
 

I have imported the right stuff, i think: sfml-networking-d.

But i still get the error:

undefined reference to `DoServerTCP(unsigned short)'

Can you help?



TobiasSmollett

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: undefined reference to `DoServerTCP(unsigned short)'
« Reply #1 on: July 18, 2012, 08:30:49 pm »
By the way, I have it in the right order too, to the best of my knowledge...

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: undefined reference to `DoServerTCP(unsigned short)'
« Reply #2 on: July 18, 2012, 10:15:35 pm »
Did you implement the function anywhere? If it's in another source file you have to add that file to your project too.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: undefined reference to `DoServerTCP(unsigned short)'
« Reply #3 on: July 19, 2012, 08:08:09 am »
The "Sockets" example is made of multiple source files. You need all of them to compile it.
Laurent Gomila - SFML developer

 

anything