Here's the situation: I'm on the heels of finishing an IDE which is somewhat of a gift to my high school CS teacher. One of the very last, and admittedly most important features of the IDE, is the ability to compile an SFML project. Currently I'm trying to get SFML to simply compile from the command prompt. These are the locations of my resources:
- main.cpp (see source below) - C:\Users\Quinn McHugh\Desktop\test\main.cpp (Nothing else in this folder)
- MinGW (unmodified lib/ and include/ directories) - C:\MinGW\include\c++\3.4.5 (this is in my path variable)
- SFML 2.1 - C:\SFML-2.1
First what I do is navigate to the folder titled test inside the command prompt, next I type the command "g++ -c -IC:\SFML-2.1\include main.cpp". As far as I can tell, this compiles without issue and produces the file main.o. Next is where the problems appear. I now try to link this whole project together with the command "g++ main.o -o main.exe -LC:\SFML-2.1\lib -DSFML_STATIC -lsfml-graphics -lsfml-window -lsfml-system", and I get these errors:
main.o:main.cpp:(.text+0xd1): undefined reference to `_imp___ZN2sf6StringC1EPKcR
KSt6locale'
main.o:main.cpp:(.text+0xf7): undefined reference to `_imp___ZN2sf9VideoModeC1Ej
jj'
main.o:main.cpp:(.text+0x132): undefined reference to `_imp___ZN2sf6WindowC1ENS_
9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
main.o:main.cpp:(.text+0x162): undefined reference to `_imp___ZN2sf6Window5close
Ev'
main.o:main.cpp:(.text+0x178): undefined reference to `_imp___ZN2sf6Window9pollE
ventERNS_5EventE'
main.o:main.cpp:(.text+0x18a): undefined reference to `_imp___ZNK2sf6Window6isOp
enEv'
main.o:main.cpp:(.text+0x1a1): undefined reference to `_imp___ZN2sf6WindowD1Ev'
main.o:main.cpp:(.text+0x1cf): undefined reference to `_imp___ZN2sf6WindowD1Ev'
main.o:main.cpp:(.text+0x1f9): undefined reference to `_imp___ZN2sf6WindowD1Ev'
collect2: ld returned 1 exit status
main.cpp:
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode(800, 600), "My window");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
}
return 0;
}
What must I change to successfully be able to run this sfml project?