When i attempt to create a sprite in my program, i get a linker error:
-------------- Build: Debug in OpenTower ---------------
Compiling: Main.cpp
Linking console executable: bin\Debug\OpenTower.exe
Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE (auto-import)
obj\Debug\Main.o(.text$_ZN2sf6SpriteD1Ev[sf::Sprite::~Sprite()]+0x3a): In function `ZNSt8_Rb_treeIPN2sf11ResourcePtrINS0_5ImageEEES4_St9_IdentityIS4_ESt4lessIS4_ESaIS4_EE11_M_put_nodeEPSt13_Rb_tree_nodeIS4_E':
G:/PortableApps/mingwportable/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_construct.h: variable 'vtable for sf::Sprite' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 5 seconds)
0 errors, 0 warnings
Sorry if i missed something obvious, i tried to look up the documentation for --enable-auto-import, but was unable to find it :/
The code i use to get this error is:
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "OpenTower");
sf::Image GroundImage, SkyImage;
system("echo %cd%");
if (!GroundImage.LoadFromFile("images\\Ground.png") ||
!SkyImage.LoadFromFile("images\\Sky.png")) {
std::cout << "Error Loading Images!";
return EXIT_FAILURE;
}
system("echo %cd%");
sf::Sprite Sky(SkyImage);
//sf::Sprite Ground(GroundImage);
//App.Draw(Sky);
//App.Draw(Ground);
system("PAUSE");
}
and i link the following libraries, in order:
- libsfml-graphics.a
- libsfml-main.a
- libsfml-window.a
- libsfml-system.a
(note that i have tried changing the order of these to the reverse, with no effect)
I also pass the following parameters to the linker:
-lsfml-graphics
-lsfml-window
-lsfml-system
I am using Code::Blocks and mingw on windows xp professional. Any help (or pointing out my obvious error) would be appreciated
.