Hello, thank you in advice for reading this!
The SFML version I am trying to get working is 2.5.1. I am working on Windows 10
I've worked with SFML before, but after I updated my IDE (Codeblocks 20.03 32 bit now) and my compiler (MinGW GCC/G++ 9.2.0 32 bit now) the compiled files stopped working. I couldn't run any examples too.
I found out this was because the library was not built with the same compiler version and settings. So I built it from source. But this newly compiled version did not have the "include" folder I have to list in Build options->Release->Search Directories->compiler. To fix that I downloaded the release build from the downloads page and copied its "include" folder in my built from source directory and then included it in my Build Options.
After all that, when I run this sample code:
#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;
}
I get the following build log:
-------------- Build: Release in sfml_swarm_intelligence (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -DSFML_STATIC -ID:\SFML-2.5.1-build\include -ID:\SFML-2.5.1-build\include -c D:\Boby\programming\CPP\kiten2019\ilia\sfml_swarm_intelligence\test.cpp -o obj\Release\test.o
g++.exe -LD:\SFML-2.5.1-build\lib -LD:\SFML-2.5.1-build\lib -o bin\Release\sfml_swarm_intelligence.exe obj\Release\test.o -s -O2 -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system -lpsapi
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj\Release\test.o:test.cpp:(.text+0x136): undefined reference to `sf::Window::isOpen() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj\Release\test.o:test.cpp:(.text+0x154): undefined reference to `sf::Window::pollEvent(sf::Event&)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x4f3): undefined reference to `wglGetProcAddress@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0xa2f): undefined reference to `wglMakeCurrent@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0xa5e): undefined reference to `wglDeleteContext@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0xb2f): undefined reference to `wglGetProcAddress@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0xbf7): undefined reference to `wglMakeCurrent@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0xd51): undefined reference to `SwapBuffers@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x1675): undefined reference to `ChoosePixelFormat@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x18c7): undefined reference to `DescribePixelFormat@16'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x18ec): undefined reference to `SetPixelFormat@12'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x1a31): undefined reference to `GetPixelFormat@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x1b2a): undefined reference to `DescribePixelFormat@16'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x287c): undefined reference to `wglMakeCurrent@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x2ab0): undefined reference to `wglCreateContext@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x2c0e): undefined reference to `wglMakeCurrent@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WglContext.cpp.obj):WglContext.cpp:(.text+0x2ce1): undefined reference to `wglShareLists@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WindowImplWin32.cpp.obj):WindowImplWin32.cpp:(.text+0x3b1): undefined reference to `GetDeviceCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(WindowImplWin32.cpp.obj):WindowImplWin32.cpp:(.text+0x3d8): undefined reference to `GetDeviceCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(CursorImpl.cpp.obj):CursorImpl.cpp:(.text+0x11f): undefined reference to `CreateDIBSection@24'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(CursorImpl.cpp.obj):CursorImpl.cpp:(.text+0x20f): undefined reference to `CreateBitmap@20'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(CursorImpl.cpp.obj):CursorImpl.cpp:(.text+0x226): undefined reference to `DeleteObject@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(CursorImpl.cpp.obj):CursorImpl.cpp:(.text+0x2c9): undefined reference to `DeleteObject@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(CursorImpl.cpp.obj):CursorImpl.cpp:(.text+0x2d7): undefined reference to `DeleteObject@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(JoystickImpl.cpp.obj):JoystickImpl.cpp:(.text+0x8f1): undefined reference to `joyGetPosEx@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(JoystickImpl.cpp.obj):JoystickImpl.cpp:(.text+0x97f): undefined reference to `joyGetPosEx@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(JoystickImpl.cpp.obj):JoystickImpl.cpp:(.text+0x9f9): undefined reference to `joyGetDevCapsW@12'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-window.a(JoystickImpl.cpp.obj):JoystickImpl.cpp:(.text+0xc98): undefined reference to `joyGetPosEx@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-system.a(SleepImpl.cpp.obj):SleepImpl.cpp:(.text+0x21): undefined reference to `timeGetDevCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-system.a(SleepImpl.cpp.obj):SleepImpl.cpp:(.text+0x2f): undefined reference to `timeBeginPeriod@4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\SFML-2.5.1-build\lib/libsfml-system.a(SleepImpl.cpp.obj):SleepImpl.cpp:(.text+0x52): undefined reference to `timeEndPeriod@4'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
32 error(s), 0 warning(s) (0 minute(s), 1 second(s))
I have listed the libraries in the linker settings in this order:
sfml-graphics
sfml-window
sfml-system
I have followed this tutorial:
https://www.sfml-dev.org/tutorials/2.5/start-cb.phpWhy do I get these errors. Is it some kind of incompatibility between the "include" files I have used and the built-from-source binaries? Hope I have not done some stupid mistake. Again, thank you in advice!