SFML community forums

Help => General => Topic started by: ZamenWolk on October 27, 2014, 08:20:24 pm

Title: Code compiling fails with cmake
Post by: ZamenWolk 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
Title: Re: Code compiling fails with cmake
Post by: Laurent on October 27, 2014, 08:31:57 pm
find_package(SFML ...)?
Title: Re: Code compiling fails with cmake
Post by: ZamenWolk 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)
Title: Re: Code compiling fails with cmake
Post by: Laurent 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)
Title: Re: Code compiling fails with cmake
Post by: Ganado 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?
Title: Re: Code compiling fails with cmake
Post by: Laurent on November 02, 2014, 10:05:44 am
You must put ${SFML_DEPENDENCIES} with other linked libraries (in the call to target_link_libraries).
Title: Re: Code compiling fails with cmake
Post by: Ganado 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.
Title: Re: Code compiling fails with cmake
Post by: Laurent 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 ;)
Title: Re: Code compiling fails with cmake
Post by: Ganado 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.
Title: Re: Code compiling fails with cmake
Post by: Laurent 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.