I can't get SFML working in Code::Blocks.
I'm using Code::Blocks 16.01. I used the tutorial (
https://www.sfml-dev.org/tutorials/2.4/start-cb.php).
Installation directory: C:\SFML-2.4.2
Project >> Build Options has:
- Project name:
-- Search directories >> Compiler: C:\SFML-2.4.2\include
-- Search directories >> Linker: C:\SFML-2.4.2\lib
- Debug:
-- Linker settings:
--- sfml-graphics-d
--- sfml-window-d
--- sfml-system-d
- Release:
-- Linker settings:
--- sfml-graphics
--- sfml-window
--- sfml-system
I used the following test code (how do I format code on this forum?):
#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;
}
When I try to build the project, I get the following errors:
-------------- Build: Release in First SFML (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LC:\SFML-2.4.2\lib -o "bin\Release\First SFML.exe" obj\Release\main.o -s -lsfml-graphics -lsfml-window -lsfml-system
obj\Release\main.o:main.cpp:(.text.startup+0xc5): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
obj\Release\main.o:main.cpp:(.text.startup+0xf5): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
obj\Release\main.o:main.cpp:(.text.startup+0xed): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
obj\Release\main.o:main.cpp:(.text.startup+0x12e): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
obj\Release\main.o:main.cpp:(.text.startup+0x133): undefined reference to `_imp___ZN2sf5Color5GreenE'
obj\Release\main.o:main.cpp:(.text.startup+0x14f): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
obj\Release\main.o:main.cpp:(.text.startup+0x172): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
obj\Release\main.o:main.cpp:(.text.startup+0x1a9): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
obj\Release\main.o:main.cpp:(.text.startup+0x1db): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
obj\Release\main.o:main.cpp:(.text.startup+0x1f3): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
obj\Release\main.o:main.cpp:(.text.startup+0x1f8): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
obj\Release\main.o:main.cpp:(.text.startup+0x214): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
obj\Release\main.o:main.cpp:(.text.startup+0x223): undefined reference to `_imp___ZN2sf6Window7displayEv'
obj\Release\main.o:main.cpp:(.text.startup+0x242): undefined reference to `_imp___ZN2sf6Window5closeEv'
obj\Release\main.o:main.cpp:(.text.startup+0x24c): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
obj\Release\main.o:main.cpp:(.text.startup+0x274): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x28a): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x302): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
obj\Release\main.o:main.cpp:(.text.startup+0x32a): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x340): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
21 error(s), 0 warning(s) (0 minute(s), 0 second(s))