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

Author Topic: Cannot compile example code / cannot find -lsfml-graphics, etc...  (Read 9109 times)

0 Members and 1 Guest are viewing this topic.

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
I can't run example code. When i'm compiling it, i have this message:
||=== Build: Debug in sfml-project01 (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lsfml-graphics|
ld.exe||cannot find -lsfml-window|
ld.exe||cannot find -lsfml-system|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I did everything as is said in this tutorial: https://www.sfml-dev.org/tutorials/2.0/start-cb.php
Additionally:

I downloaded and installed this: TDM 4.9.2 (64-bit), codeblocks-16.01-setup.exe, source code of sfml 2.4.2 and made sfml with cmake. Then I created new project, new file.cpp, copied code, and after compilation I had those error messages. After that I followed few YouTube tutorials, tried static and non static version of configuration and nothing changed
I have Windows 10 64bit if this is important.
Here are pics of configuration:



sjaustirni

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #1 on: February 21, 2017, 07:16:30 pm »
Just a quick thought - what is the contents of C:/SFML/lib? Have you moved the compiled libraries to this folder you refer to in C::B?

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #2 on: February 21, 2017, 07:28:35 pm »
When i was ask if path to te lib should be relative, i answered no. So i think, this should be full path to the folder where i have all files, that was made by cmake from SFML 2.4.2.. This folder is C:\SFML.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #3 on: February 21, 2017, 07:29:52 pm »
And what's the content of the directory?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #4 on: February 21, 2017, 07:34:22 pm »
/bin/openal32.dll
/cmake/Modules/FindSFML.cmake
/include/SFML/Audio,Graphics,Network,System,Window folders, and header files
/lib/*.a
/license.txt
/readme.txt
« Last Edit: February 21, 2017, 07:40:25 pm by MDK »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #5 on: February 21, 2017, 09:25:26 pm »
Don't make assumptions about how things work on Windows based on your experience with Linux, or rather don't give out advice based on these assumptions. ;)

MinGW (GCC) still uses .a files for static libs and import/definition libraries.

So what are the names of these *.a files?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #6 on: February 21, 2017, 10:10:34 pm »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #7 on: February 21, 2017, 10:37:18 pm »
So how do you expect GCC to find "sfml-graphics" if your directory only contains "sfml-graphics-s"? ;)

If you want to link the static version, you have to add the -s suffix and define SFML_STATIC.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #8 on: February 21, 2017, 11:04:39 pm »
I did everything like on this tutorial:https://www.youtube.com/watch?v=0LGzJP3k7M4
And now have this:

Can problem be somewhere else, because i checked it twice doing above. And why my directory contain only -s versions of these files?
« Last Edit: February 22, 2017, 01:09:18 am by MDK »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #9 on: February 21, 2017, 11:15:49 pm »
The error message is pretty clear. It can't find the specified libraries. And you know why it can't find it, because they don't exist in the specified location.

If you for example just build the static release (-s) set of SFML libraries you'll just have that one version of them. If you now also want the static debug (-s-d) set of SFML libraries, you'll have to adjust the CMake settings and build that set.
In other words, CMake doesn't build all possible variations, but just the one you specify.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #10 on: February 22, 2017, 01:19:51 am »
That solved the problem with missing debug files. But now I have another one. After compiling project there is something like that:

I thought that this could be problem with downloaded file, so I redownloaded it and CMake it again. And outcome is the same. Then I downloaded this ready to use file:GCC 4.9.2 TDM (SJLJ) - 64-bit and same thing happened. I am starting to believe in this Murphy law: Anything That Can Possibly Go Wrong, Does.
« Last Edit: February 22, 2017, 01:24:01 am by MDK »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #11 on: February 22, 2017, 01:47:57 am »
Read the official tutorial again. Especially the part about linking statically. Make sure it's for the latest SFML version.
« Last Edit: February 22, 2017, 01:49:36 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #12 on: February 22, 2017, 02:08:52 am »
Yes: Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well.
Thanks for help and for your patience.

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #13 on: February 23, 2017, 06:41:28 am »
There were a few missing dependencies in the tutorial for me, namely "jpeg" and I think one or two others.

This is a good list to start with:

sfml-graphics-s
freetype
jpeg
sfml-window-s
opengl32
gdi32
sfml-system-s
winmm

Do not include the file extensions or even path if you are using Code::Blocks and following the tutorial. Just type these in as-is. That tripped me up for a while.

To my knowledge, all of those were required to compile that program for me on windows. I may be wrong about freetype, but jpeg is for sure.
« Last Edit: February 23, 2017, 06:59:51 am by Argus »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Cannot compile example code / cannot find -lsfml-graphics, etc...
« Reply #14 on: February 23, 2017, 08:08:45 am »
They are all listed in the tutorial, you just have to read the latest tutorial. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/