SFML community forums

Help => System => Topic started by: Maxim Kuzmin on April 01, 2020, 06:50:45 pm

Title: Class constructor throws exeption
Post by: Maxim Kuzmin on April 01, 2020, 06:50:45 pm
I am getting started with SFML with Visual Studio 2019. I followed this tuttorial and launched the app successfuly. But without any changes to the code I launched it one more time and it gives me this error:

Exception thrown at 0x53582687 (sfml-system-2.dll) in Voidger.exe: 0xC0000005: Access violation reading location 0x0000016E. occurred

on this line:

RenderWindow window(VideoMode(200, 200), "SFML works!"); //not really
 
Ever since the app will output the same error and will occasionaly create a window if some magic stars allign. When I discovered the error I tried to create a new project but had issue with linker so abanded it as the other app didn't even start.

Here is the full code (provided on official website):

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

using namespace sf;

int main()
{
    std::cout << "H\n";

    RenderWindow window(VideoMode(200, 200), "SFML works!"); // error line
    CircleShape shape(100.f);
    shape.setFillColor(Color::Green);

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

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

    return 0;
}
The funniest thing is that the code always launches, outputs the h in cmd and most of times exits with code -1073741819.
Title: Re: Class constructor throws exeption
Post by: Laurent on April 01, 2020, 08:24:22 pm
Make sure that you're not compiling in Debug mode while linking to release SFML libraries.
Title: Re: Class constructor throws exeption
Post by: Maxim Kuzmin on April 02, 2020, 12:11:33 pm
I am not. ALso I cant use debug mode because MSVCR120D.dll is missing
Title: Re: Class constructor throws exeption
Post by: Maxim Kuzmin on April 02, 2020, 12:18:55 pm
I tried creating a new project but
LINK : fatal error LNK1181: cannot open input file 'sfml-system.dll'
is poping up. I have setup include and lib folders in project properties and checked so that it would be as in tutorial and for All Configurations. I have also copied contents of bin folder to the project folder (where main.cpp is). So a new project should be identical to the one I tried to troubleshoot in this thred but they have different errors ???
Title: Re: Class constructor throws exeption
Post by: eXpl0it3r on April 07, 2020, 10:10:11 am
You're linking DLLs instead of import *.lib files. ;)