M
M
Mihis2019-04-17 19:12:58
C++ / C#
Mihis, 2019-04-17 19:12:58

Why is the SFML application not compiling?

I wanted to make a graphical application in SFML (2.5.1), but when compiling the code, the same error constantly occurs.
Development Environment: Eclipse Cpp

15:49:16 **** Incremental Build of configuration Debug for project vanilla ****
Info: Internal Builder is used for build
g++ -o vanilla.exe "src\\log.o" "src\\vanilla.o" "-lC:\\Users\\vsach\\Documents\\cpp-libs\\SFML-2.5.1\\lib" 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\Users\vsach\Documents\cpp-libs\SFML-2.5.1\lib
collect2.exe: error: ld returned 1 exit status

The code itself:
#include <SFML/Graphics.hpp>

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();
    }

    return 0;
}

PS The question has been changed.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mihis, 2019-12-02
@Mihis

I installed Linux, and now I don't suffer with it. (I don't consider this a solution since I ran away from the problem, not solved it)

V
Vitaly Stolyarov, 2019-04-17
@Ni55aN

You need to set the path to the SFML binaries. The undefined reference to error says that it sees the function in .h files, but does not find its implementation in the included libraries
https://codeyarns.com/2013/09/22/how-to-add-librar...
https: //stackoverflow.com/questions/48367503/undef...

J
jcmvbkbc, 2019-04-17
@jcmvbkbc

g++ -o app.exe "src\\log.o" "src\\app.o"

you need to add something like -lsfml-graphics -lsfml-window -lsfml-system to the end.
See https://www.sfml-dev.org/tutorials/2.5/start-linux.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question