Hi, I have experience with C++ and the basics of SFML.
I would like to have MinGW and SFML on a USB Drive. What I've done is create a folder and moved all of the MinGW stuff to it. (C:/MinGW to the folder) Then, what I've done is download SFML 2.0 RC, the GCC DW2 version and extracted it. I put them both on the usb and start trying to get SFML to work, but I get a linking error.
I tried without using SFML, and compiling non-SFML related programs (such as the classic "Hello World!" program) and it worked fine. Only SFML (and possibly other ones too) doesn't work.
I try the following:
g++ test.cpp -ISFML/include/ -LSFML/lib/ -lsfml-graphics
and it gives me this error:
C:\Users\Joe\Desktop>g++ test.cpp -ISFML/include/ -LSFML/lib/ -lsfml-graphics
C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o:test.cpp:(.text+0x92): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o:test.cpp:(.text+0x145): undefined reference to `_imp___ZN2sf6Window5closeEv'
C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o:test.cpp:(.text+0x15d): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o:test.cpp:(.text+0x1e3): undefined reference to `_imp___ZN2sf6Window7displayEv'
C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o:test.cpp:(.text+0x1f2): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
c:/users/joe/desktop/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: C:\Users\Joe\AppData\Local\Temp\ccPRI8Sp.o: bad reloc address 0xe in section `.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]'
c:/users/joe/desktop/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Oh by the way, the reason why it says Desktop is because I'm testing it on the Desktop instead of the usb (it should work anyways, regardless of desktop or on usb stick.
I am running MSYS so I could easily change directories and then compile the code. Also, the code sample I'm using is:
#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;
}
Something is wrong when it's trying to link SFML. Also, I've redownloaded SFML GCC DW2 and MinGW multiple times, it's not that. I'm probably doing something wrong that I'm not realizing, hopefully someone could help me out.
If you have any questions, please ask, thanks.