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

Author Topic: Newly Compiled sfml not working.(SOLVED)  (Read 7400 times)

0 Members and 1 Guest are viewing this topic.

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Newly Compiled sfml not working.(SOLVED)
« on: January 08, 2017, 12:46:19 am »
I bid hello to this great community, it's nice to be in such a great place, will make sure to share my new sfml projects with you guys!!!! But sadly I cannot do that yet because.....

I had found out that so I can work with sfml 2.4.1, I must recompile it with CMake and Code::Blocks, the IDE I'm using. The compiling process was successful, but once I wanted to set up the project the fun started....
I had to face 50 errors first. Now I have reduced them to 5.
Here are the errors!
Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-2.4.1\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d -lglew -lfreetype -ljpeg -lopenal32 -lopengl32 -mwindows
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lglew
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lfreetype
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -ljpeg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lopenal32
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
5 error(s), 0 warning(s) (0 minute(s), 1 second(s)) 0 second(s)


The compiler itself works fine, I said Hello to the world and it was fine.
Now, here are my linkers:
https://www.dropbox.com/s/u4tmzgr5dhcdba6/linkers.PNG?dl=0

I am grateful for your help, and hope to have the solution to this problem to be done pretty soon.
« Last Edit: January 10, 2017, 12:28:36 am by Lord Wolfram »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Newly Compiled sfml not working.
« Reply #1 on: January 08, 2017, 01:47:48 am »
When you build SFML, you should build the install target, that way you get all the proper libs installed. Also follow the official and most recent tutorial for Code::Blocks, because GLEW isn't part of SFML for a long time already...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Re: Newly Compiled sfml not working.
« Reply #2 on: January 08, 2017, 03:00:55 pm »
When you build SFML, you should build the install target, that way you get all the proper libs installed. Also follow the official and most recent tutorial for Code::Blocks, because GLEW isn't part of SFML for a long time already...

Well then, I tried to rebuild the entire thing, followed the tutorials and yet again got these errors:
Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -g -I"D:\Projects\C++\SFML Games\SFML\SFML-2.4.1\include" -c "D:\Projects\C++\SFML Games\Aurelium\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-d -lsfml-window-d -lsfml-system-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system-d
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 3 second(s))
4 error(s), 0 warning(s) (0 minute(s), 3 second(s))

Well this time there are only 4 of them. I honestly have no idea what is here being done wrong.
NOTE: I used to work in Visual C++ .NET
My friend told me to move to Code::Blocks
I followed the latest version and latest tutorials. But no, not working.

My Code::Blocks version- codeblocks-16.01mingw

Compiler GNU GCC Compiler

OS: Microsoft Windows 7

Maybe I must download specific SFML version? Any would work that's 2.0 or so.
Or maybe other Code::Blocks version. Compiling process seems to be not a solution for some reason.

Thank you for your help!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Newly Compiled sfml not working.
« Reply #3 on: January 08, 2017, 03:10:10 pm »
Did you read the error message? Do you understand what the error message is saying?

If a file can't be found it pretty much always has one of those three reasons:

1. File doesn't exist
2. The application (i.e. linker) doesn't know where to look
3. The application (i.e. linker) doesn't have the permission to read the specified directory

Do the sfml-xyz-d files exist?
Have you told the linker where to find them?
Does the directory have special permission requirements?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Re: Newly Compiled sfml not working.
« Reply #4 on: January 08, 2017, 03:18:39 pm »
The files in Debug build of SFML are named like this:
sfml-graphics-s

But the tutorial specified that I must write -d. In any case I changed the -d to -s
making it into sfml-graphics-s-d causes an error just like the one above.

But if we just link this:
sfml-graphics-s
We get a new set of errors:

Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
obj\Debug\main.o: In function `main':
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:6: undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:7: undefined reference to `_imp___ZN2sf5Color5GreenE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:7: undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:15: undefined reference to `_imp___ZN2sf6Window5closeEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:12: undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:18: undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:18: undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:19: undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:19: undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:20: undefined reference to `_imp___ZN2sf6Window7displayEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:9: undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
obj\Debug\main.o: In function `ZN2sf11CircleShapeD1Ev':
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
21 error(s), 0 warning(s) (0 minute(s), 1 second(s))

Now what?

Thank you for your help so far!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Newly Compiled sfml not working.
« Reply #5 on: January 08, 2017, 06:43:14 pm »
Do you understand the difference between static and dynamic (aka shared) libraries? If not, you should make yourself familiar with that.

sfml-xyz stands for dynamic release libraries
sfml-xyz-d stands for dynamic debug libraries
sfml-xyz-s stands for static release libraries
sfml-xyz-s-d stands for static debug libraries

As pointed out in the tutorial, if you link SFML statically, you have to add SFML_STATIC to you compiler definitions and you have to link all of SFML's dependencies (see the table in tutorial).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Re: Newly Compiled sfml not working.
« Reply #6 on: January 08, 2017, 10:46:59 pm »
Thank you so far for your help, the errors have been reduced to 9.
So as far as I understand it, the compiler cannot find the dependencies? How to make him find that, I saw no files with those names.

Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s -lsfml-window-s -lsfml-audio-s -lsfml-system-s -lopengl32 -lfreetype -ljpeg -lwinmm -lgdi32 -lopenal32 -lflac -lvorbisenc -lvorbisfile -lvorbis -logg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lfreetype
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -ljpeg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lopenal32
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lflac
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbisenc
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbisfile
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbis
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -logg
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
9 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

Who knows maybe the linker order is wrong.
https://www.dropbox.com/s/9phba8mfh182ai4/Capture.PNG?dl=0

So yeah, what do we do now.

Thank you for your help!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Newly Compiled sfml not working.
« Reply #7 on: January 08, 2017, 11:30:31 pm »
The dependencies are shipped with SFML's source code. When building the INSTALL project or target the dependencies would get installed automatically. Since you apparently didn't do that, you'll have to copy them manually from the extlibs/libs-mingw/x86 directory.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Re: Newly Compiled sfml not working.
« Reply #8 on: January 09, 2017, 12:18:17 am »
The dependencies are shipped with SFML's source code. When building the INSTALL project or target the dependencies would get installed automatically. Since you apparently didn't do that, you'll have to copy them manually from the extlibs/libs-mingw/x86 directory.

Funny enough but when I compiled both Debug and Release, I did use the install target.

Alright, where I place those libs?
Alongside the .exe or where exactly.
« Last Edit: January 09, 2017, 04:39:23 am by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Newly Compiled sfml not working.
« Reply #9 on: January 09, 2017, 04:40:47 am »
Where ever you have placed the SFML libs.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Newly Compiled sfml not working.
« Reply #10 on: January 09, 2017, 10:18:33 am »
you shouldn't have to build sfml with cmake

codeblocks and sfml works right out of the box

http://en.sfml-dev.org/forums/index.php?topic=21243.msg151540#msg151540

but learning to compile SFML is a good learning experience
so you might want to continue and get it working

Lord Wolfram

  • Newbie
  • *
  • Posts: 11
  • Books give you knowledge, but knowledge is power!
    • ICQ Messenger - 136
    • View Profile
    • Andris Ivanovs - Programmer, Game Developer
Re: Newly Compiled sfml not working.
« Reply #11 on: January 10, 2017, 12:28:17 am »
Thanks both of you for your great help, I finally managed to set up the project quite nicely.
Best regards to both of you.
JamesL, thru art a true help, thanks to you I made it running great, you should put your tutorial as an official one.

eXpl0it3r, thru art a true help  too. Thanks to you I have learned more about libraries. I am used to see them with the extension .dll but now I know more than that.

Thanks both of you. Now I shall advance to making games, and thee shall see some fine pieces.