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

Author Topic: LNK2019 unresolved external symbol [SOLVED]  (Read 342 times)

0 Members and 1 Guest are viewing this topic.

Justbod

  • Newbie
  • *
  • Posts: 9
    • View Profile
LNK2019 unresolved external symbol [SOLVED]
« on: October 07, 2023, 02:44:09 pm »
I've been wanting to experiment with the SFML Network module. Unfortunately I'm running into some issues. I setup the Project with the Visual Studio guide on the SFML website. Everything worked fine, the green circle rendered and the standard "SFML works!" text got printed in the console. I followed the first networking guide step by step and ran into this issue.

Any help is greatly appreciated!

Both applications have the exact same issue so I believe that I setup something incorrectly. I checked if I had linked the .dll files and placed them in the correct directory and found no issues.

This is the Client application:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        sf::UdpSocket socket;

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Could not bind socket on port 54000";
        }

        char data[100] = "test";

        sf::IpAddress recipient = "127.0.0.1";
        unsigned short port = 54000;

        if (socket.send(data, 100, recipient, port) != sf::Socket::Done)
        {
                std::cout << "Failed to send data";
        }

        return 0;
}
 

This is the server application:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        sf::UdpSocket socket;

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Could not bind socket on port 54000!";
        }

        char data[100];
        std::size_t received;

        //UDP socket
        sf::IpAddress sender;
        unsigned short port;
        if (socket.receive(data, 100, received, sender, port) != sf::Socket::Done)
        {
                std::cout << "Failed to receive data!";
        }

        std::cout << "Received " << received << " bytes from " << sender << " on port " << port << std::endl;

        return 0;
}
 

EDIT: literally seconds after posting this I discovered that I had linked all .DLL files except the network one, oops!  ::)
« Last Edit: October 07, 2023, 02:47:55 pm by Justbod »
🧃🦔

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: LNK2019 unresolved external symbol [SOLVED]
« Reply #1 on: October 10, 2023, 08:01:29 am »
EDIT: literally seconds after posting this I discovered that I had linked all .DLL files except the network one, oops!  ::)
We've all been there. Posting a question, only to answer it directly afterwards. :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/