Search code examples
c++g++sfml

SFML c++ program throws an error "Entry point not found" when running


I recently started learning c++ and now I'm somewhat familiar with c++. But this is my first SFML program and I don't have any experience using third party libraries. I made my first SFML program to open a window. But it doesn't run and throws an error.

main.cpp

#include <iostream>
#include <SFML/Graphics.hpp>

int main() {
    sf::Window playground = sf::Window(sf::VideoMode(640, 480), "Sanke");

    while (playground.isOpen()) {
        sf::Event event;

        while (playground.pollEvent(event)) {
            switch (event.type) {
                case sf::Event::Closed:
                playground.close();
                break;
            }
        }

        playground.display();
    }
    return 0;
}

I created a bat file to run this.

main.bat

@echo off

g++ main.cpp -o main.exe -IC:/Users/USER/Desktop/project/SFML-2.5.1/include -LC:/Users/USER/Desktop/project/SFML-2.5.1/lib -lsfml-system -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-network

main.exe

Then I placed all the dll files in the sfml/bin/ to the project directory. When I run the main.bat file It throws out this error.

main.exe - Entry Point Not Found

The procedure entry point
_ZNSt15basic_streambuflcSt11char_traitslcEE7seekposESt4fpo
sliEST13_los_Openmode could not be located in the dynamic link library C:\Users\User\Desktop\project\sfml-system-2.dll

I searched this up for hours. But I have no idea how to fix this. Even followed some tutorials. Any help would be appreciated.


Solution

  • Program worked after adding c++ standard(std=c++17) to the compiler command

    g++ main.cpp -o main.exe -IC:/Users/USER/Desktop/project/SFML-2.5.1/include -LC:/Users/USER/Desktop/project/SFML-2.5.1/lib -lsfml-system -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-network -std=c++17