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

Author Topic: Issues getting SFML to work with the QT IDE  (Read 2933 times)

0 Members and 6 Guests are viewing this topic.

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Issues getting SFML to work with the QT IDE
« on: February 18, 2018, 12:22:07 pm »
Hi all, I built SFML 2.4.2 as Static Linking and this is the build output for SFML (I added in the contents of <SFML Source Dir>\extlibs\libs-mingw\x86 to <Build Output>\lib just incase it was an issue with missing dependencies but still got the same errors).

Here is the .pro file contents for the QT project I created to test that SFML was properly set up (but ultimately failed)

And here is the Compiler Output

Now for Screenshots of my SFML Source CMake Config

Debug


Release

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Issues getting SFML to work with the QT IDE
« Reply #1 on: February 18, 2018, 12:29:54 pm »
You have to define SFML_STATIC.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #2 on: February 18, 2018, 12:33:54 pm »
Ah... my bad... I used this tutorial in order to get stuff going with QT. It is designed for Dynamic Linking and so I adapted it for Static Linking but forgot about that Compiler option... Thanks  :-[

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #3 on: February 18, 2018, 01:43:51 pm »
I've just looked into the errors and there are missing include files from the Source. Things like "GLCheck.hpp" aren't in the include directory of SFML's Source

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Issues getting SFML to work with the QT IDE
« Reply #4 on: February 18, 2018, 03:26:27 pm »
Quote
I've just looked into the errors
Which errors?

Quote
Things like "GLCheck.hpp" aren't in the include directory of SFML's Source
It's under "src", not "include".
Laurent Gomila - SFML developer

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #5 on: February 18, 2018, 04:35:47 pm »
Quote
I've just looked into the errors
Which errors?

Quote
Things like "GLCheck.hpp" aren't in the include directory of SFML's Source
It's under "src", not "include".

A fresh Compilation log
(click to show/hide)

And here is a screenshot of one of the missing headers attached  too

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Issues getting SFML to work with the QT IDE
« Reply #6 on: February 18, 2018, 04:39:26 pm »
When you link SFML statically you must link to all its dependencies too (check the "Getting started" tutorials).

Quote
And here is a screenshot of one of the missing headers attached too
That's just the IDE, the compiler doesn't seem to have problems with those headers.
Laurent Gomila - SFML developer

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #7 on: February 18, 2018, 04:55:49 pm »
Then I don't know why the test code (the one at the end of the configuration tutorials on the SFML website) won't compile...

EDIT

I have figured it out... it was the order of stuff that was the issue. I had the libs that depended on other libs after those libs.

For people who stumble upon this thread looking for the solution, I got you fam  ;D

Here is what you add to your <Project_Name>.pro file
//Library Directories Configuration
LIBS += -L<Debug_Binaries_Base_Dir>\lib -L<Release_Binaries_Base_Dir>\lib -L<SFML_Source_Base_Dir>\extlibs\libs-mingw\x86

//Release Library Configuration
CONFIG(release, debug|release): LIBS += -llibsfml-audio-s -llibopenal32 -llibFLAC -llibvorbisenc -llibvorbisfile -llibvorbis -llibogg -llibsfml-graphics-s -llibfreetype -llibjpeg -llibsfml-network-s -lws2_32 -llibsfml-window-s -lopengl32 -lgdi32 -llibsfml-system-s -lwinmm

//Debug Library Configuration
CONFIG(debug, debug|release): LIBS += -llibsfml-audio-s-d -llibopenal32 -llibFLAC -llibvorbisenc -llibvorbisfile -llibvorbis -llibogg -llibsfml-graphics-s-d -llibfreetype -llibjpeg -llibsfml-network-s-d -lws2_32 -llibsfml-window-s-d -lopengl32 -lgdi32 -llibsfml-system-s-d -lwinmm

INCLUDEPATH += <SFML_Source_Base_Dir>\include
DEPENDPATH += <SFML_Source_Base_Dir>\include

//SFML_STATIC preprocessor definition
DEFINES += SFML_STATIC

 

EDIT 2
This is the forum post that I found that solved my issue (for those of you that are curious)

EDIT 3
I had forgotten to add the libraries for the Audio and Network modules. I also have rearranged the libs dependency libs (the ones like Freetype and GDI32) so that they are before the SFML libs that don't need them.
« Last Edit: February 18, 2018, 06:19:47 pm by JamesYeoman »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Issues getting SFML to work with the QT IDE
« Reply #8 on: February 18, 2018, 07:33:31 pm »
Quote
-llibsfml-audio-s
Should be -lsfml-audio-s (same for all other libs).
Laurent Gomila - SFML developer

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #9 on: February 18, 2018, 08:13:08 pm »
Quote
-llibsfml-audio-s
Should be -lsfml-audio-s (same for all other libs).

My generated libs had the "lib" prefix i.e. instead of sfml-system-s-d.a being generated, libsfml-system-s-d.a was generated. It is most likely just a quirk of the QT IDE because the test program (in the spoiler for convenience) ran perfectly fine
(click to show/hide)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Issues getting SFML to work with the QT IDE
« Reply #10 on: February 18, 2018, 09:10:10 pm »
The point is more that it's no needed, but it will work regardless. GCC will automatically add the lib prefix and .a suffix, so -lsfml-audio-s-d is equivalent to -llibsfml-audio-s-d.a
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JamesYeoman

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Issues getting SFML to work with the QT IDE
« Reply #11 on: February 18, 2018, 09:16:17 pm »
The point is more that it's no needed, but it will work regardless. GCC will automatically add the lib prefix and .a suffix, so -lsfml-audio-s-d is equivalent to -llibsfml-audio-s-d.a

Oh, that's pretty awesome. I guessed that the .a would be added but I didn't realise that the lib was also added.

 

anything