Help getting TGUI running - OpenGL

  • 7 Replies
  • 949 Views
Help getting TGUI running - OpenGL
« on: 01 May 2021, 03:39:34 »
I'm using CodeLite 12.0.3 on MacOS 10.14.2, with SFML 2.5.1 (I think correctly) installed.
I can start a new project and paste in the minimal TGUI code and it will compile and open a blank window. However, the terminal displays this notice when it runs:
Code: [Select]
objc[9998]: Class SFViewController is implemented in both /Library/Frameworks/./sfml-window.framework/Versions/2.5.1/sfml-window (0x10fbd30a8) and /usr/local/lib/libsfml-window.2.5.dylib (0x10d8120a8). One of the two will be used. Which one is undefined.
, along with the same notice for about 7 other Classes.

Then, if I try to add a Button to the GUI object, it compiles, but in the terminal I get:
Code: [Select]
sfml-graphics requires support for OpenGL 1.1 or greater
Ensure that hardware acceleration is enabled if available

Do I need extra software or settings in order to run TGUI without any hitches? Thanks!
I should mention, that I'm pretty new to C++, so all the config is still a little bewildering for me...

John Ziegler

*

texus

  • *****
  • 1631
    • View Profile
    • Texus's Blog
Re: Help getting TGUI running - OpenGL
« Reply #1 on: 01 May 2021, 09:07:40 »
The error about SFViewController means that your project is linking to both the SFML framework and the dylib file, while you should only link to one of them.

The opengl error is probably caused because one SFML version gets initialized properly while the second one isn't initialized and believes it has no opengl support.

In your project you are probably only linking to one of these versions, but TGUI will be linking to the other one. You need to make certain to use the same SFML version in your project and when building TGUI. So how did you install TGUI exactly?

Re: Help getting TGUI running - OpenGL
« Reply #2 on: 02 May 2021, 04:37:19 »
I built TGUI from source with Cmake, but I don't remember all of the options I selected or deselected. I think I was going for using the dylibs. After building the source, I just went in to the CodeLite project Settings->Linker->Libraries and typed in "libtgui-d.0.9.1.dylib" in addition to the SFML dylibs that were there.

I tried erasing the SFML dylibs from that Libraries line (thinking maybe it was already using the frameworks?), but got a linker error:
Code: [Select]
Undefined symbols for architecture x86_64:
"sf::RenderWindow::RenderWindow(...
more

When I left the dylibs in the Libraries field and tried to manually remove the SFML frameworks from MacintoshHD/Library/Frameworks directory, it compiled but launching the minimal program failed with this message in the terminal:
Code: [Select]
dyld: Library not loaded: @rpath/sfml-graphics.framework/Versions/2.5.1/sfml-graphics
  Referenced from: /usr/local/lib/libtgui-d.0.9.1.dylib
  Reason: image not found
Abort trap: 6
Thanks for replying...
« Last Edit: 02 May 2021, 04:41:43 by johnnywz00 »

*

texus

  • *****
  • 1631
    • View Profile
    • Texus's Blog
Re: Help getting TGUI running - OpenGL
« Reply #3 on: 02 May 2021, 14:27:37 »
It seems like TGUI links to the frameworks then.

I don't think there is an easy way to choose whether TGUI links to dylibs or frameworks in CMake, it probably uses the first one it finds (unless you either set SFML_DIR manually or show the advanced options and manually change the paths of the SFML libraries).

So the solution is probably to either link to the SFML frameworks in your project, or to rebuild TGUI after removing the files from that Library/Frameworks folder (because TGUI will then find the SFML dylib files instead of the frameworks).
Edit: After thinking about it, TGUI might fail to find SFML when the frameworks are removed (when attempting to build TGUI with cmake again). There is an SFMLConfig.cmake file which TGUI finds and that one probably still points to the framework. So you would have to delete that file as well, or set SFML_DIR to a different location. Just keeping TGUI unchanged and linking to the SFML frameworks in your project thus sounds like the easier solution.
« Last Edit: 02 May 2021, 14:32:06 by texus »

Re: Help getting TGUI running - OpenGL
« Reply #4 on: 02 May 2021, 22:46:20 »
Alas, I don't know how to tell my IDE to link to frameworks as opposed to dylibs. I tried pasting the framework filenames into the Linker Settings->Libraries: field, replacing the dylibs with them, but that didn't work.

I'm attaching a screenshot of the Cmake options that come preset. Can you possibly point to which ones I should modify that might correct this?
Sorry for the trouble! I'm no computer guru...

*

texus

  • *****
  • 1631
    • View Profile
    • Texus's Blog
Re: Help getting TGUI running - OpenGL
« Reply #5 on: 02 May 2021, 22:53:22 »
I can't help you with that IDE. The only thing I know is how the command that is passed to the linker should look like: for dylibs it should be "-lXXX.dylib" while for frameworks it should be "-framework XXX".

To find a different SFML version you have to change the SFML_DIR option. The value has to be the directory that contains a file called SFMLConfig.hpp. I can't tell you which folder this is, as it depends on your SFML installation, but suppose SFML is installed to /usr/local then the folder would most likely be /usr/local/lib/cmake/SFML.

Alternatively you could always install SFML and TGUI using homebrew.

Re: Help getting TGUI running - OpenGL
« Reply #6 on: 03 May 2021, 06:41:59 »
Okay, I'll look into those options... thanks for your help!

Re: Help getting TGUI running - OpenGL
« Reply #7 on: 07 May 2021, 07:06:04 »
Working! Looking forward to exploring my C++ programming with your GUI...