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

Author Topic: Class constructor throws exeption  (Read 7053 times)

0 Members and 1 Guest are viewing this topic.

Maxim Kuzmin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Class constructor throws exeption
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Class constructor throws exeption
« Reply #1 on: April 01, 2020, 08:24:22 pm »
Make sure that you're not compiling in Debug mode while linking to release SFML libraries.
Laurent Gomila - SFML developer

Maxim Kuzmin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Class constructor throws exeption
« Reply #2 on: April 02, 2020, 12:11:33 pm »
I am not. ALso I cant use debug mode because MSVCR120D.dll is missing

Maxim Kuzmin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Class constructor throws exeption
« Reply #3 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 ???

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Class constructor throws exeption
« Reply #4 on: April 07, 2020, 10:10:11 am »
You're linking DLLs instead of import *.lib files. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/