Search code examples
visual-studiocmakesfml

SFML 2.5.1 Error LNK1112 module machine type 'x86' conflicts with target machine type 'x64'


Im trying to use the SFML library in Visual Studio 2019. Ended up having that error. I created binary files using source code and cmake which was set defaulted to x64 generator. I followed and linked all the libraries and dependencies.

I even followed this and couldn't get to resolve the issue

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


I'm new to the VS and programming. Any help especially noob friendly would be appreciated


Solution

  • The error is caused by you trying to mix 32 bit and 64 bit files. If your project is 64 bit (x64), you'll also need a 64 bit of SFML (and all other dependencies). Same is true for 32 bit (x86).