Ok I'll admit I am not the best coder but I am trying to learn. I know a good bit of Java and wanted to learn C++ to expand my repertoire. I want to solidify my skills in C++ by creating Chess using the SFML library. I installed SFML from https://github.com/andrew-r-king/sfml-vscode-boilerplate and I ran the main.cpp that came with the boilerplate, it worked. However I am trying to replicate it in a separate file however I can't get it to compile. I am compiling it with g++, and it doesn't work. I don't seem to know why.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(512, 512), "Chess by Nabid Kabir", sf::Style::Titlebar | sf::Style::Close);
while (window.isOpen())
{
sf::Event e;
while(window.pollEvent(e))
{
if(e.type == e.Closed)
{
window.close();
}
}
}
return 0;
}
this is the error I get when I try to build and run
Starting build...
Build finished with errors(s):
Undefined symbols for architecture x86_64:
"sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in chess-e62717.o
"sf::RenderWindow::~RenderWindow()", referenced from:
_main in chess-e62717.o
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in chess-e62717.o
"sf::Window::close()", referenced from:
_main in chess-e62717.o
"sf::Window::pollEvent(sf::Event&)", referenced from:
_main in chess-e62717.o
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
_main in chess-e62717.o
"sf::Window::isOpen() const", referenced from:
_main in chess-e62717.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process terminated with exit code: -1.
Can anyone help, I don't really understand configuring libraries that well as this is my first time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…