简体   繁体   中英

Cant run SFML library in netbeans on ubuntu

Hi i want to add SFML for a graphical project in c++ but i get this error when i try to run som basic code:

free(): invalid pointer: 0x00000000009ace48 ***

And in netbeans properties under c++ compiler i have added the SFML/include folder in the include directories
And under linker and additionally library directory i have the sfml/lib folder
And last under linker and in the library i have added sfml-graphics-sd, sfml-audio-sd, sfml-network-sd, sfml-window-sd and sfml-system-sd in that order.

This is the code i want to run:

#include <cstdlib>
#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;
}

The SFML window is opening and directly closes and then i get:

RUN FINISHED; Aborted; core dumped; real time: 240ms; user: 20ms; system: 30ms

and the error i told in the start

Do any one know if its me that have added the library wrong or what it can be. thanks for help

Edit: for now i have solved it by using a makefile and writing it in a text editor but i wonder if i can use same method in netbeans?

This is how my makefile looks and it works but i would like to be able to do it all in netbeans:

all:
    g++ -std=c++11  *.cpp  -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

clean:
    rm -rf *.o sfml-app

I think you have added wrong libraries, you should use "-d" libraries in case of dynamic linking. "-sd" libraries are being used for static linking. In case you want to use static linking you need to define SFML_STATIC macro for preprocessor in your project. And you should add additional libraries, such as opengl32.lib, and others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM