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

Author Topic: SFML for GCC 13.2.0  (Read 322 times)

0 Members and 1 Guest are viewing this topic.

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
SFML for GCC 13.2.0
« on: November 04, 2024, 05:20:06 pm »
When will SFML have a GCC 13.2.0 compatible build?   MSYS only download is 13.2.0 and it is near impossible to get an 13.1.0.

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 57
    • View Profile
Re: SFML for GCC 13.2.0
« Reply #1 on: November 04, 2024, 05:37:53 pm »
I'd recommend using the CMake project template so that you don't have to wait on us to distribute more binaries. It's really simple to use and works with all compilers.

https://github.com/SFML/cmake-sfml-project

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML for GCC 13.2.0
« Reply #2 on: November 04, 2024, 08:26:42 pm »
I've tried CMAKE (mingw32-make GCC for Windows 10) and it builds through 80% - with linked libraries built for system, main, window, and network.  But at 80% it fails when trying to link shared library graphics:

[ 80%] Linking CXX shared library ..\..\..\lib\sfml-graphics-2.dll
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/SFML-2.6.1/extlibs/libs-mingw/x64/libfreetype.a(sfnt.c.obj):sfnt.c:(.text+0x5614): undefined reference to `_setjmp'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/SFML-2.6.1/extlibs/libs-mingw/x64/libfreetype.a(smooth.c.obj):smooth.c:(.text+0x77a): undefined reference to `_setjmp'
collect2.exe: error: ld returned 1 exit status

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 57
    • View Profile
Re: SFML for GCC 13.2.0
« Reply #3 on: November 04, 2024, 09:02:16 pm »
You followed the instructions in https://github.com/SFML/cmake-sfml-project and this is the error you got? The template is structured such that those kinds of linker errors won't happen. I encourage you to follow the instructions in that link and your problem will likely go away.

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML for GCC 13.2.0
« Reply #4 on: November 04, 2024, 10:18:21 pm »
AT the link you passed, it shows the following.  But that does not appear to build a SFML compatible with my current C++ compiler (GCC 13.2.0).   I've been using the cmake gui to set configuration and then generate a MakeFile in my build directory.  I then use mingw32-make in the command prompt to build the compatible version of SFML.  Is this the right process?   Install Git and CMake. Use your system's package manager if available.

Follow GitHub's instructions for how to use their project template feature to create your own project.

Clone your new GitHub repo and open the repo in your text editor of choice.

Open CMakeLists.txt. Rename the project and the executable to whatever name you want.

If you want to add or remove any .cpp files, change the source files listed in the add_executable call in CMakeLists.txt to match the source files your project requires. If you plan on keeping the default main.cpp file then no changes are required.

If your code uses the Audio or Network modules then add sfml-audio or sfml-network to the target_link_libraries call alongside the existing sfml-graphics library that is being linked.

If you use Linux, install SFML's dependencies using your system package manager. On Ubuntu and other Debian-based distributions you can use the following commands:

sudo apt update
sudo apt install \
    libxrandr-dev \
    libxcursor-dev \
    libudev-dev \
    libfreetype-dev \
    libopenal-dev \
    libflac-dev \
    libvorbis-dev \
    libgl1-mesa-dev \
    libegl1-mesa-dev
Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part.

VS Code via the CMake extension
Visual Studio
CLion
Qt Creator
Using CMake from the command line is straightforward as well. Be sure to run these commands in the root directory of the project you just created.

cmake -B build
cmake --build build
Enjoy!

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 57
    • View Profile
Re: SFML for GCC 13.2.0
« Reply #5 on: November 04, 2024, 10:33:52 pm »
If you follow the instructions it will build a compatible version of SFML. It will use your same compiler to build SFML. Just try it out. I promise it'll help.

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML for GCC 13.2.0
« Reply #6 on: November 05, 2024, 06:10:32 pm »
I cloned the SFML template onto my computer C: root directory.   But cannot get past line 2 of CmakeLists.txt.  I get

CMake Error at CMakeLists.txt:2 (project):
  Running

   'nmake' '-?'

  failed with:

   no such file or directory

Am I supposed to rename "project" in line 2 of CmakeLists.txt to the file folder that has the template.   

In FetchContent am I supposed to change GIT_REPOSITORY https://github.com/SFML/SFML.git to the folder on my computer?


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11027
    • View Profile
    • development blog
    • Email
Re: SFML for GCC 13.2.0
« Reply #7 on: November 05, 2024, 09:46:20 pm »
The default CMake generator is for Visual Studio, since you want to use GCC, you may need to explicitly pick a different generator.

First make sure gcc, g++ and make/mingw32-make are in PATH.
Next delete the created build directory build/ to start with a clean setup.
Then instead of just running cmake -B build, run instead cmake -B build -G "MinGW Makefiles"
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML for GCC 13.2.0
« Reply #8 on: November 06, 2024, 02:29:50 am »
Using your recommended command prompt entry (cmake -B build -G "MinGW Makefiles"), SFML 2.6.1 builds under 13.2.0 but with libraries scattered in multiple sub-directories.   And I am back to the same error I got with the 13.1.0 version of SFML 2.6.1.  Adn I have seen that multiple people are getting the "undefined reference to __imp__ZN2sf6StringC1EPKcRKSt6locale" and similar.   Below is the error readout from attempting to compile a simple C++ program using VS Code IDE.

C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WINDOWS\TEMP\cchHTVoD.o: in function `main':
C:/Users/dbrya/projects/installation/SFML_main.cpp:5:(.text+0x83): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:5:(.text+0xa7): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:5:(.text+0xe8): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:11:(.text+0x11f): undefined reference to `__imp__ZN2sf6Window5closeEv'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:9:(.text+0x133): undefined reference to `__imp__ZN2sf10WindowBase9pollEventERNS_5EventE'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:7:(.text+0x147): undefined reference to `__imp__ZNK2sf10WindowBase6isOpenEv'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:16:(.text+0x160): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/dbrya/projects/installation/SFML_main.cpp:16:(.text+0x1a8): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
collect2.exe: error: ld returned 1 exit status

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11027
    • View Profile
    • development blog
    • Email
Re: SFML for GCC 13.2.0
« Reply #9 on: November 06, 2024, 08:32:14 am »
For UCRT-based compilers you need to use the SFML 2.6.x branch, as we've only added support for those in up coming version.

However it seems like you're not linking SFML.
Are you really using the template?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bryantdr

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML for GCC 13.2.0
« Reply #10 on: November 06, 2024, 06:07:51 pm »
Yes, I am using the template form github.  I create a private repo of the SFML template, close it to my computer and then use the CMakeLists with no changes.   Then do  "cmake -B build -G "MinGW Makefiles"" then "cmake --build build" on the Windows 10 Command Prompt   It builds fine and ends with main.exe created.   And main pulls up a window with a moving bee - so it appears to work with cmake.  Hurrah!

But, what I am really trying to do is to build GCC 13.2.0 compatible SFML libraries to link into C++ programs using VS Code to compile and link.   I guess I need to do the step in the github template instructions that say to do the build with VS Code, but I do not know what the "project" would be to do it in VS Code.  Do you agree?   What file in the template would I use for the project file to build in VS Code?