Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: undefined reference errors using built from source SFML  (Read 2673 times)

0 Members and 1 Guest are viewing this topic.

CDnoMlqko

  • Newbie
  • *
  • Posts: 5
    • View Profile
undefined reference errors using built from source SFML
« on: July 26, 2020, 08:22:42 pm »
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.php

Why 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!
« Last Edit: July 27, 2020, 04:12:52 pm by CDnoMlqko »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference errors using built from source SFML
« Reply #1 on: July 28, 2020, 10:19:59 am »
You seem to link SFML twice. Make sure you don't have them defined twice in the linker settings.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CDnoMlqko

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: undefined reference errors using built from source SFML
« Reply #2 on: July 28, 2020, 11:52:15 am »
Yes, I had linked it both in the global project settings and in the release settings. I fixed it and the output does not change much:
-------------- Build: Release in sfml_swarm_intelligence (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -DSFML_STATIC -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 -o bin\Release\sfml_swarm_intelligence.exe obj\Release\test.o  -s -O2  -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))
 
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference errors using built from source SFML
« Reply #3 on: July 28, 2020, 02:11:09 pm »
You defined SFML_STATIC so you need to link the static SFML libraries (suffix -s).
Also when linking statically you need to link SFML's dependencies, as stated in the official tutorials.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CDnoMlqko

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: undefined reference errors using built from source SFML
« Reply #4 on: July 28, 2020, 02:34:58 pm »
I changed the linked libraries to:
sfml-graphics-s
freetype
glew32
sfml-window-s
gdi32
opengl32
sfml-system-s
winmm
 
and now the error is different. Progress made.
-------------- Build: Release in sfml_swarm_intelligence (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -DSFML_STATIC -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 -o bin\Release\sfml_swarm_intelligence.exe obj\Release\test.o  -s -O2  -lsfml-graphics-s -lfreetype -lglew32 -lsfml-window-s -lgdi32 -lopengl32 -lsfml-system-s -lwinmm -lpsapi
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lfreetype
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lglew32
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
3 error(s), 0 warning(s) (0 minute(s), 1 second(s))
 
 
do I have to download these libraries?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference errors using built from source SFML
« Reply #5 on: July 28, 2020, 02:51:00 pm »
You must have checked out an old tutorial, see the list here: https://www.sfml-dev.org/tutorials/2.5/start-cb.php

glew32 isn't used anymore and freetype comes with SFML. Make sure if you built SFML yourself, that you built the INSTALL target, that way CMake will copy all necessary libraries to the install directory
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CDnoMlqko

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: undefined reference errors using built from source SFML
« Reply #6 on: July 28, 2020, 05:23:42 pm »
How do I build the INSTALL target? I saw this in some tutorial, but I did not find a setting in CMake that accounts this.

And, after I removed freetype and glew32, this is the error:
g++.exe -LD:\SFML-2.5.1-build\lib -o bin\Release\sfml_swarm_intelligence.exe obj\Release\test.o  -s -O2  -lsfml-graphics-s -lsfml-window-s -lgdi32 -lopengl32 -lsfml-system-s -lwinmm -lpsapi
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: obj\Release\test.o:test.cpp:(.text+0x49): 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+0x61): undefined reference to `sf::Window::pollEvent(sf::Event&)'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

Edit: I looked at the tutorial again: https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php
and I see that the target must be specified in the make command, building the library, but as I used CodeBlocks to do it, I have no direct access to the build command? So I must correct my question: How do i do this in codeblocks?
« Last Edit: July 28, 2020, 08:13:28 pm by CDnoMlqko »

 

anything