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

Author Topic: [SOLVED] SFML 2.5.1 with CMake on CLion: undefined reference to ...  (Read 1837 times)

0 Members and 2 Guests are viewing this topic.

alexmjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
Seems to be a common issue but I couldn't find any way to get this to work.
With SFML 2.5.1 and g++ 8.2.0-5, my situation (Project folder, CMakeLists.txt and result) is the following:
see attachment

I'm at my wits end, the current CMakeLists.txt is the most logical one I've constructed so far and I don't understand why it is unable to properly link everything.
« Last Edit: February 08, 2020, 08:49:58 am by alexmjes »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML 2.5.1 with CMake on CLion: undefined reference to ...
« Reply #1 on: January 30, 2020, 09:09:41 am »
There's nothing after your "is the following". ;)

The common cause is not linking SFML at all, linking SFML in the wrong order or linking mismatching non-static/static or debug/release libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

alexmjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML 2.5.1 with CMake on CLion: undefined reference to ...
« Reply #2 on: January 30, 2020, 10:05:30 am »
Thank you for the quick reply!

Sorry for the newbie mistake, couldn't get [img] tags to work. There is now an image attached to the original post.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML 2.5.1 with CMake on CLion: undefined reference to ...
« Reply #3 on: January 30, 2020, 12:56:05 pm »
For the last few errors, you probably want to link the runtime library statically if you previously built SFML with static standard libraries.

For the references to your code, it seems like some issue within your own code. Cyclic dependency? Missing header guard? Missing implementations?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

alexmjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML 2.5.1 with CMake on CLion: undefined reference to ...
« Reply #4 on: January 31, 2020, 11:15:47 am »
I managed to get SFML to work. I clearly have little knowledge about static and dynamic libraries, but omitting the "set true" for sfml static libraries was a step in the right direction. Right now, just getting started is important for me, so I will look into this subject in the future.

Next, I copied all the .dll-s from SFML-2.5.1/bin to the cmake-build-release that CMake built. This was enough for the executable to now work properly.

Thanks again for your help, eXpl0it3r, it put me on the right path.