Reputation: 17
I have attached SFML files in my main.cpp file for writing some games in c++. I wanted to add some images so, I included SFML files with the help of following includes:
#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;
When I compiled my source code then linker errors like
undefined reference to __imp occurred.
Following are the errors:
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x2b6): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x2e1): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x335): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x374): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x38e): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x3a8): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x418): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x4ad): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x542): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x588): undefined reference to `__imp__ZN2sf6SpriteC1ERKNS_7TextureE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x5ca): undefined reference to `__imp__ZN2sf6SpriteC1ERKNS_7TextureE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x615): undefined reference to `__imp__ZN2sf5ClockC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x634): undefined reference to `__imp__ZNK2sf5Clock14getElapsedTimeEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x655): undefined reference to `__imp__ZNK2sf4Time9asSecondsEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x670): undefined reference to `__imp__ZN2sf5Clock7restartEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x6a7): undefined reference to `__imp__ZN2sf6Window5closeEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x713): undefined reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x730): undefined reference to `__imp__ZN2sf8Keyboard12isKeyPressedENS0_3KeyE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd5c): undefined reference to `__imp__ZN2sf5Color5WhiteE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd71): undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd81): undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xda0): undefined reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xe76): undefined reference to `__imp__ZN2sf6Sprite14setTextureRectERKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xec0): undefined reference to `__imp__ZN2sf13Transformable11setPositionEff'
collect2: ld returned 1 exit status
There are many other errors like this.
Upvotes: 1
Views: 1114
Reputation:
if you are using an IDE, you i'd want to do something like this:
(right click on your project, click build options, and then click linker settings)
if not do like sanka said
Upvotes: 0
Reputation: 33
In SFML you need to compile with some flags :
g++ -o ... -lsfml-graphics -lsfml-window -lsfml-system
Upvotes: 0