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

Author Topic: Code compiling fails with cmake  (Read 3010 times)

0 Members and 1 Guest are viewing this topic.

ZamenWolk

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Code compiling fails with cmake
« on: October 27, 2014, 08:20:24 pm »
Hello everybody,

So I'm trying this new IDE called CLion, and I need to use cmake to compile my code. I learnt a lot on that, and I've been trying to make SFML work properly with it, but it keeps giving me weird errors after it creates the .obj files. Can someone help ?

Here are the errors when I compile :

(click to show/hide)

Here is my CMakeLists.cmake file :

(click to show/hide)

I am using static linkage of SFML, I have compiled SFML myself, with the version of MinGW I'm using, and this is the master build I downloaded off GitHub

Thanks all for your help, I'm really lost here.

Happy coding,
ZamenWolk

EDIT : Fixed errors
« Last Edit: October 27, 2014, 08:47:55 pm by ZamenWolk »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Code compiling fails with cmake
« Reply #1 on: October 27, 2014, 08:31:57 pm »
find_package(SFML ...)?
Laurent Gomila - SFML developer

ZamenWolk

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Code compiling fails with cmake
« Reply #2 on: October 27, 2014, 08:41:16 pm »
Oh oops. It's actually an error, I deleted it accidentally before posting because I tested other things. I added it now, and I have these errors :

(click to show/hide)

Here is the new cmakelist
(click to show/hide)
« Last Edit: October 27, 2014, 08:47:42 pm by ZamenWolk »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Code compiling fails with cmake
« Reply #3 on: October 27, 2014, 10:08:31 pm »
Two mistakes:

1. The libraries order is important, as stated in the gcc tutorial
2. When you link statically you must also link the SFML dependencies (${SFML_DEPENDENCIES} CMake variable)
Laurent Gomila - SFML developer

Ganado

  • Newbie
  • *
  • Posts: 34
  • Moo, I say.
    • View Profile
    • FOnline Engine, check it out.
Re: Code compiling fails with cmake
« Reply #4 on: November 02, 2014, 05:54:59 am »
Hi Laurent, I got similar errors. I'm new to cmake (I was able to follow this site's tutorial on building SFML but nothing besides that) but I must've missed the bit about linking SFML dependencies so that there aren't undefined OpenGL references.

Could you explain where exactly I should put that ${SFML_DEPENDENCIES} line?  Is it an option on the Cmake GUI or do I have to manually edit a cmake file?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Code compiling fails with cmake
« Reply #5 on: November 02, 2014, 10:05:44 am »
You must put ${SFML_DEPENDENCIES} with other linked libraries (in the call to target_link_libraries).
Laurent Gomila - SFML developer

Ganado

  • Newbie
  • *
  • Posts: 34
  • Moo, I say.
    • View Profile
    • FOnline Engine, check it out.
Re: Code compiling fails with cmake
« Reply #6 on: November 02, 2014, 06:29:03 pm »
Okay and just to make sure, this is within the file
Code: [Select]
SFML-master/cmake/Modules/FindSFML.cmake?[/s]

Edit: Wait no it's not in FindSFML.cmake, it's just a comment in that file.
I don't know what file I'm supposed to edit to link statically correctly...


My apologies if this is written in the tutorial but I can't find it.
« Last Edit: November 02, 2014, 06:50:20 pm by Ganado »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Code compiling fails with cmake
« Reply #7 on: November 02, 2014, 07:00:53 pm »
I think you have no idea of what you're doing, and that is because you don't use CMake. Am I right? If you're not using CMake for your own project, then you're completely off-topic here.

If I'm wrong, and you're using CMake, then you'd better learn how to use it first ;)
Laurent Gomila - SFML developer

Ganado

  • Newbie
  • *
  • Posts: 34
  • Moo, I say.
    • View Profile
    • FOnline Engine, check it out.
Re: Code compiling fails with cmake
« Reply #8 on: November 02, 2014, 07:53:51 pm »
Sorry I thought I was on topic and that my issue was similar enough not to make a new thread.
My error messages were very similar to the topic's.

That's correct I have no idea what I am doing. I was trying to follow the site's tutorial on how to compile SFML (I thought that was what ZamenWolk was trying to do as well), and I ran into these problems when trying to statically link things.

I thought that the tutorial provided by the site would be all I need to do this basic thing, but I am wrong? Thanks for the replies. I guess this is off topic so I'll stop.
« Last Edit: November 02, 2014, 08:01:08 pm by Ganado »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Code compiling fails with cmake
« Reply #9 on: November 02, 2014, 10:05:36 pm »
Ok... so yes, you're off-topic. Please open a new thread, and describe your problem precisely (give as much details as possible, as explained in the "Read before posting" sticky post).

Let's go back to the initial poster & problem.
Laurent Gomila - SFML developer