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

Author Topic: Generating sfml with CMake  (Read 3905 times)

0 Members and 1 Guest are viewing this topic.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Generating sfml with CMake
« on: May 12, 2015, 05:02:44 pm »
I'm probably being stupid with this, but it's the first time I've ever got CMake to work so I'm a bit confused. I'm also not sure what relevant information to give so if someone would tell me what information would be helpful, I'll happily give it. I followed the tutorial exactly and I generated MinGW makefiles in C:\Documents\sfmltest. However I'm not sure how to actually link them to my project now, seeing as the generated files and folders didn't contain that which is distributed in the pre-built versions. As I said I know I'm probably missing something fundamental, but I got stuck after generating (which seems to have worked fine) and I just don't know what to do now.
Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #1 on: May 12, 2015, 05:17:37 pm »
As you have said yourself, CMake only generates makefiles (or project files). In order to get the built library, you now have to actually run the compiler. Since you said to have generated a "MinGW Makefiles", then all you need to do is open a command line window, browse to the build directory that you specified in CMake, make sure the compiler is in PATH - add it if not - and run mingw32-make install.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #2 on: May 12, 2015, 05:19:18 pm »
Ah okay, thanks. Is there no way to do it without using the command prompt?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #3 on: May 12, 2015, 05:22:37 pm »
You'd have to generate a project file for Code::Blocks or so, but honestly that's just more work than opening a cmd. :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #4 on: May 12, 2015, 05:33:50 pm »
Just done that (had to google how to use the cmd) and after it had done all the Building CXX objects lines and got to 100%, it came up with this:
Install the porject...
-- Install configuration: "Release"
-- Installing: C:/Program Files (x86)/SFML/./include
CMake Error at cmake_install,cmake:32 (file):
  file INSTALL cannot make directory "C:/Program Files (x86)/SFML/,/include":
  No such file or directory

makefile:84: recipe for target 'install' failed
mingw32-make: *** [install] Error 1

It seems fairly self explanatory as to what it has done but I'm still confused as to why it's trying to put some libraries in program files when I didn't specify that, and what I can do to get it to work. As usual, any help would be appreciated.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #5 on: May 12, 2015, 05:35:21 pm »
You did, but you didn't notice since it's the CMake default value.

Go back to your CMake configuration and change the path for CMAKE_INSTALL_PREFIX. Of course you'll have to regenerate the makefile after the path changed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #6 on: May 12, 2015, 05:45:20 pm »
Did that and it was working, until it came up with this after installing loads of hpp files:
CMake Error at scmake_install.cmake:35 (file):
  file INSTALL cannot copy file "C:/SFMLsource/SFML2.3.license.txt" to
  "C:/./license.txt".


makefile:84: recipe for target 'install' failed
mingw32-make: *** [install] Error 1

For the reference, I set the install prefix to C:/ because I reasoned that it couldn't have a problem with installing directly to the C drive. I'm so grateful for all the help everyone on here gives, and it makes me feel really stupid when everything I try just fails and I have to come here every time.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Generating sfml with CMake
« Reply #7 on: May 12, 2015, 05:56:05 pm »
You should install into a specific folder. C:/ is usually protected and you need some rights to install there. You could create a folder at the root of C:/ like C:/Sfml-Install/ and install in there. Or just anywhere else really.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #8 on: May 12, 2015, 06:08:55 pm »
Yay more errors, I've installed it now and the command line came up with no errors. Now that I've linked it, these errors come up when I use the test program on the tutorial section of the website:
-------------- Build: Release in sfmlLinkingTest (compiler: GNU GCC Compiler)---------------

i686-w64-mingw32-g++.exe -LC:\SFMLbuild\lib -o bin\Release\sfmlLinkingTest.exe obj\Release\main.o  -s  -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lfreetype -ljpeg -lopengl32 -lgdi32 -lwinmm
obj\Release\main.o:main.cpp:(.text.startup+0x7a): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
obj\Release\main.o:main.cpp:(.text.startup+0xa2): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
obj\Release\main.o:main.cpp:(.text.startup+0xe4): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
obj\Release\main.o:main.cpp:(.text.startup+0x117): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
obj\Release\main.o:main.cpp:(.text.startup+0x11c): undefined reference to `_imp___ZN2sf5Color5GreenE'
obj\Release\main.o:main.cpp:(.text.startup+0x12e): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
obj\Release\main.o:main.cpp:(.text.startup+0x134): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
obj\Release\main.o:main.cpp:(.text.startup+0x148): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
obj\Release\main.o:main.cpp:(.text.startup+0x198): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
obj\Release\main.o:main.cpp:(.text.startup+0x1aa): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
obj\Release\main.o:main.cpp:(.text.startup+0x1af): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
obj\Release\main.o:main.cpp:(.text.startup+0x1cb): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
obj\Release\main.o:main.cpp:(.text.startup+0x1da): undefined reference to `_imp___ZN2sf6Window7displayEv'
obj\Release\main.o:main.cpp:(.text.startup+0x1eb): undefined reference to `_imp___ZN2sf6Window5closeEv'
obj\Release\main.o:main.cpp:(.text.startup+0x1f5): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
obj\Release\main.o:main.cpp:(.text.startup+0x213): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x21f): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x25e): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
obj\Release\main.o:main.cpp:(.text.startup+0x26d): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
obj\Release\main.o:main.cpp:(.text.startup+0x28b): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
20 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 
Could anyone use their infinite wisdom to explain these?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #9 on: May 12, 2015, 06:29:18 pm »
Read the tutorial again about static linking. ;)

You didn't define SFML_STATIC yet you link statically against the SFML libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #10 on: May 12, 2015, 06:31:30 pm »
Actually I did define it, I've just checked and it is there.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #11 on: May 12, 2015, 06:34:45 pm »
It's not in the command line that gets run, so where ever you defined it, isn't the right place.

i686-w64-mingw32-g++.exe -LC:\SFMLbuild\lib -o bin\Release\sfmlLinkingTest.exe obj\Release\main.o  -s  -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lfreetype -ljpeg -lopengl32 -lgdi32 -lwinmm

Make sure that it gets applied for the release settings as well.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #12 on: May 12, 2015, 06:42:48 pm »
Okay this makes no sense, I've put "SFML_STATIC" in both the top level project settings and the release settings and it still comes up with exactly the same errors, as soon as I press compile. It does exactly the same things if I put it in just the project settings or just the release settings. I have no other build targets to I have no idea what's going on here.
EDIT: I don't have to put the -s on the non sfml libraries do I?
EDIT2: Is there nothing else that could cause those errors?
« Last Edit: May 12, 2015, 07:10:59 pm by shadowmouse »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Generating sfml with CMake
« Reply #13 on: May 12, 2015, 07:47:49 pm »
EDIT: I don't have to put the -s on the non sfml libraries do I?
Don't add the -s for non SFML libraries.

Can you provide a screenshot of where you've placed the SFML_STATIC?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Generating sfml with CMake
« Reply #14 on: May 12, 2015, 08:22:18 pm »
I've tried both with and without it being defined in the release. The photos are attached.
« Last Edit: May 12, 2015, 08:24:44 pm by shadowmouse »