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

Author Topic: Getting SFML to work (SFML/*: no such file or directory)  (Read 13422 times)

0 Members and 1 Guest are viewing this topic.

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Getting SFML to work (SFML/*: no such file or directory)
« on: January 11, 2017, 11:44:44 am »
Hey!

I am trying to get SFML working for at least two hours now.
Currently my problem is that if I try to compile the tutorial (http://www.sfml-dev.org/tutorials/2.4/start-cb.php), it says

Quote
||=== Build: Debug in SFML project (compiler: GNU GCC Compiler) ===|
D:\C++\Projekte\SFML project\main.cpp|1|fatal error: SFML/Graphics.hpp: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

which is very frustrating.
I am using Code::Blocks with SFML 2.4.1. I tried to set everything up in the Project's Build Options which didnt work so I tried doing everything in the compiler settings (I copied the default GNU GCC compiler and changed the settings at the new one).

Here are some Screenshots:
http://imgur.com/a/fWNra

regards, TPRammus

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #1 on: January 11, 2017, 01:24:35 pm »
Since you copied the compiler settings, you need to make sure to switch the project to the new compiler.
But it's not recommended to add library path to your compiler settings, just add them to the project settings and make sure they apply properly for the wanted targets.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #2 on: January 11, 2017, 01:42:12 pm »
Thank you for your help Sir. That solved this one issue.
I actually thought, that the compiler you select in the Compiler settings would be used.

But now I have a ton of undefined references for whatever reason. And I am pretty sure I selected the right version...

Quote
||=== Build: Debug in SFML project (compiler: GNU GCC Compiler (SFML 2.4.1)) ===|
obj\Debug\main.o||In function `main':|
D:\C++\Projekte\SFML project\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
D:\C++\Projekte\SFML project\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
D:\C++\Projekte\SFML project\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
D:\C++\Projekte\SFML project\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
D:\C++\Projekte\SFML project\main.cpp|7|undefined reference to `sf::Color::Green'|
D:\C++\Projekte\SFML project\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
D:\C++\Projekte\SFML project\main.cpp|15|undefined reference to `sf::Window::close()'|
D:\C++\Projekte\SFML project\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
D:\C++\Projekte\SFML project\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
D:\C++\Projekte\SFML project\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
D:\C++\Projekte\SFML project\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
D:\C++\Projekte\SFML project\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
D:\C++\Projekte\SFML project\main.cpp|20|undefined reference to `sf::Window::display()'|
D:\C++\Projekte\SFML project\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
D:\C++\Projekte\SFML project\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
D:\C++\Projekte\SFML project\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||error: ld returned 1 exit status|
||=== Build failed: 20 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

regards, TPRammus

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #3 on: January 11, 2017, 03:32:25 pm »
Undefined references means that the linker couldn't find the specified functions, which means that you most likely didn't link the right libraries.
If you use the project settings, make sure to add the libraries for release and debug mode.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #4 on: January 11, 2017, 03:52:36 pm »
Do I have to set it up in the project settings? Because it would be way more comfortable to just switch the compiler to the SFML version every time I work with SFML.
Also, I think that I linked all libraries right.
You can see the list on the third picture: http://imgur.com/a/fWNra

regards, TPRammus

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #5 on: January 11, 2017, 08:32:46 pm »
Okay I reinstalled Code::Blocks and SFML now completely. (Yeah all files including the ones in %appdata% etc)
I think the problem might have been that I chose the 64 bit version of SFML even tho I had the 32 bit compiler installed?
Anyway, this time I chose 32 bit with the 32 bit compiler. And now I get other errors (but they are still undefined reference-errors):
Code: [Select]
-------------- Clean: Debug in SFML_Test_TEST (compiler: GNU GCC Compiler (SFML 2.4.1))---------------

Cleaned "SFML_Test_TEST - Debug"

-------------- Build: Debug in SFML_Test_TEST (compiler: GNU GCC Compiler (SFML 2.4.1))---------------

mingw32-g++.exe -Wall -g -std=c++11 -DGLEW_STATIC -DSFML_STATIC -DUNICODE -IC:\SFML-2.4.1\include -c D:\C++\Projekte\SFML_Test_TEST\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LC:\SFML-2.4.1\lib -o bin\Debug\SFML_Test_TEST.exe obj\Debug\main.o   C:\SFML-2.4.1\lib\libsfml-graphics-s.a C:\SFML-2.4.1\lib\libfreetype.a C:\SFML-2.4.1\lib\libjpeg.a C:\SFML-2.4.1\lib\libsfml-window-s.a C:\SFML-2.4.1\lib\libsfml-audio-s.a C:\SFML-2.4.1\lib\libopenal32.a C:\SFML-2.4.1\lib\libFLAC.a C:\SFML-2.4.1\lib\libvorbisenc.a C:\SFML-2.4.1\lib\libvorbisfile.a C:\SFML-2.4.1\lib\libvorbis.a C:\SFML-2.4.1\lib\libogg.a C:\SFML-2.4.1\lib\libsfml-network-s.a C:\SFML-2.4.1\lib\libsfml-system-s.a
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x34f): undefined reference to `glClearColor@16'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9c8): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9d0): undefined reference to `glPopMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9dc): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9e4): undefined reference to `glPopMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9f0): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9f8): undefined reference to `glPopMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x9fd): undefined reference to `glPopClientAttrib@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xb9e): undefined reference to `glViewport@16'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xbad): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xbc6): undefined reference to `glLoadMatrixf@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xbd5): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xe19): undefined reference to `glBlendFunc@8'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xf5a): undefined reference to `glDisable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xf69): undefined reference to `glDisable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xf78): undefined reference to `glDisable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xf87): undefined reference to `glDisable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xf96): undefined reference to `glEnable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xfa5): undefined reference to `glEnable@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xfb4): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xfc3): undefined reference to `glEnableClientState@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xfd2): undefined reference to `glEnableClientState@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xfe1): undefined reference to `glEnableClientState@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x100e): undefined reference to `glLoadMatrixf@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10c1): undefined reference to `glPushClientAttrib@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10d0): undefined reference to `glPushAttrib@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10df): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10e7): undefined reference to `glPushMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10f3): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x10fb): undefined reference to `glPushMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x1107): undefined reference to `glMatrixMode@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x110f): undefined reference to `glPushMatrix@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x11dd): undefined reference to `glLoadMatrixf@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x1200): undefined reference to `glLoadMatrixf@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x12ca): undefined reference to `glVertexPointer@16'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x12f4): undefined reference to `glColorPointer@16'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x131e): undefined reference to `glTexCoordPointer@16'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x1344): undefined reference to `glDrawArrays@12'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x364): undefined reference to `glClear@4'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0xa05): undefined reference to `glPopAttrib@0'
C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0x1443): undefined reference to `glLoadMatrixf@4'
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: C:\SFML-2.4.1\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj): bad reloc address 0x98 in section `.rdata'
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
42 error(s), 0 warning(s) (0 minute(s), 1 second(s))
 

regards, TPRammus

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Getting SFML to work (SFML/*: no such file or directory)
« Reply #6 on: January 11, 2017, 08:43:45 pm »
You forgot to link OpenGL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #7 on: January 11, 2017, 09:05:10 pm »
The only problem is that there is no opengl32, the only thing I can find is openal32. (see attachment)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #8 on: January 11, 2017, 10:36:14 pm »
It's a system library, same for winmm, ws_32, etc.
Your compiler knows where to find them, so you just have to add their names to the library list.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TPRammus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Getting SFML to work (SFML/*: no such file or directory)
« Reply #9 on: January 11, 2017, 11:00:17 pm »
Yes! Finally! It works now.
Thank you very much for your patience and have a nice day :)

regards, TPRammus

 

anything