I'm having trouble with the c library SFML I'm trying to make a simple and portable game for fun and as a challenge. I've decided to use SFML as it looks easy.
The problem is that every time I try to link the library I get a linking error. No mater where the files are located it always dosen't work. So I thought it was some Visual Studio error. So my instinct decited to switch to a dev c project. That didn't work either. I followed many tutorials looked at many forms for nothing to work. By the way i did the EXACTLY same thing in Visual Studio as in Dev C so i will not be showing screenshots of VS 2022
#include<iostream>
#include<Windows.h>
#include "SFML/Graphics.hpp"
/*int WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
}*/
//For Debbuining. The one above is for release
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();
}
}
SCREENSHOTS
I was expecting a window to pop up and show a green circle.
CodePudding user response:
I recommend vcpkg.
First, install vcpkg and then sfml(vcpkg install sfml).
You can use sfml in visual studio.
By the way, you need to comment out #include <Windows.h>
.
After set up you can use #include <SFML/Graphics.hpp>
, too.