It is still not working, even after compiling it. I still have the same error message undefined reference to `sf::Font::loadFromFile(std::string const&)'|
and similar errors: ||=== Build: Debug in moj_projekt (compiler: GNU GCC Compiler) ===|
obj/Debug/EditorState.o||In function `EditorState::EditorState(sf::RenderWindow&, Cliff&)':|
/home/paulo/Dokumenti/moj_projekt/EditorState.cpp|13|undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'|
/home/paulo/Dokumenti/moj_projekt/EditorState.cpp|22|undefined reference to `sf::Font::loadFromFile(std::string const&)'|
obj/Debug/EditorState.o||In function `EditorState::run()':|
/home/paulo/Dokumenti/moj_projekt/EditorState.cpp|99|undefined reference to `sf::String::String(std::string const&, std::locale const&)'|
obj/Debug/MenuState.o||In function `MenuState::MenuState(sf::RenderWindow&, Cliff&)':|
/home/paulo/Dokumenti/moj_projekt/MenuState.cpp|9|undefined reference to `sf::Font::loadFromFile(std::string const&)'|
||error: ld returned 1 exit status|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Make log:
paulo@omgHaxor:~/Downloads/SFML-make$ sudo make install
[ 16%] Built target sfml-system
[ 38%] Built target sfml-window
[ 48%] Built target sfml-network
[ 79%] Built target sfml-graphics
[100%] Built target sfml-audio
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/./include
-- Installing: /usr/local/./include/SFML
-- Installing: /usr/local/./include/SFML/Main.hpp
-- Installing: /usr/local/./include/SFML/Window
-- Installing: /usr/local/./include/SFML/Window/Mouse.hpp
-- Installing: /usr/local/./include/SFML/Window/WindowHandle.hpp
-- Installing: /usr/local/./include/SFML/Window/Event.hpp
-- Installing: /usr/local/./include/SFML/Window/Context.hpp
-- Installing: /usr/local/./include/SFML/Window/VideoMode.hpp
-- Installing: /usr/local/./include/SFML/Window/Window.hpp
-- Installing: /usr/local/./include/SFML/Window/Joystick.hpp
-- Installing: /usr/local/./include/SFML/Window/ContextSettings.hpp
-- Installing: /usr/local/./include/SFML/Window/Keyboard.hpp
-- Installing: /usr/local/./include/SFML/Window/Touch.hpp
-- Installing: /usr/local/./include/SFML/Window/Sensor.hpp
-- Installing: /usr/local/./include/SFML/Window/Export.hpp
-- Installing: /usr/local/./include/SFML/Window/WindowStyle.hpp
-- Installing: /usr/local/./include/SFML/Window/GlResource.hpp
-- Installing: /usr/local/./include/SFML/Network
-- Installing: /usr/local/./include/SFML/Network/TcpSocket.hpp
-- Installing: /usr/local/./include/SFML/Network/SocketSelector.hpp
-- Installing: /usr/local/./include/SFML/Network/Socket.hpp
-- Installing: /usr/local/./include/SFML/Network/SocketHandle.hpp
-- Installing: /usr/local/./include/SFML/Network/Http.hpp
-- Installing: /usr/local/./include/SFML/Network/Ftp.hpp
-- Installing: /usr/local/./include/SFML/Network/TcpListener.hpp
-- Installing: /usr/local/./include/SFML/Network/Packet.hpp
-- Installing: /usr/local/./include/SFML/Network/IpAddress.hpp
-- Installing: /usr/local/./include/SFML/Network/UdpSocket.hpp
-- Installing: /usr/local/./include/SFML/Network/Export.hpp
-- Installing: /usr/local/./include/SFML/Audio.hpp
-- Installing: /usr/local/./include/SFML/Window.hpp
-- Installing: /usr/local/./include/SFML/Graphics
-- Installing: /usr/local/./include/SFML/Graphics/VertexArray.hpp
-- Installing: /usr/local/./include/SFML/Graphics/ConvexShape.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Shape.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Color.hpp
-- Installing: /usr/local/./include/SFML/Graphics/RenderTarget.hpp
-- Installing: /usr/local/./include/SFML/Graphics/RenderWindow.hpp
-- Installing: /usr/local/./include/SFML/Graphics/PrimitiveType.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Transformable.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Image.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Font.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Texture.hpp
-- Installing: /usr/local/./include/SFML/Graphics/RenderStates.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Transform.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Rect.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Glyph.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Vertex.hpp
-- Installing: /usr/local/./include/SFML/Graphics/CircleShape.hpp
-- Installing: /usr/local/./include/SFML/Graphics/BlendMode.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Rect.inl
-- Installing: /usr/local/./include/SFML/Graphics/Drawable.hpp
-- Installing: /usr/local/./include/SFML/Graphics/View.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Sprite.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Shader.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Text.hpp
-- Installing: /usr/local/./include/SFML/Graphics/RenderTexture.hpp
-- Installing: /usr/local/./include/SFML/Graphics/RectangleShape.hpp
-- Installing: /usr/local/./include/SFML/Graphics/Export.hpp
-- Installing: /usr/local/./include/SFML/Network.hpp
-- Installing: /usr/local/./include/SFML/System
-- Installing: /usr/local/./include/SFML/System/MemoryInputStream.hpp
-- Installing: /usr/local/./include/SFML/System/Vector2.inl
-- Installing: /usr/local/./include/SFML/System/Mutex.hpp
-- Installing: /usr/local/./include/SFML/System/ThreadLocal.hpp
-- Installing: /usr/local/./include/SFML/System/Time.hpp
-- Installing: /usr/local/./include/SFML/System/InputStream.hpp
-- Installing: /usr/local/./include/SFML/System/ThreadLocalPtr.hpp
-- Installing: /usr/local/./include/SFML/System/ThreadLocalPtr.inl
-- Installing: /usr/local/./include/SFML/System/Vector3.hpp
-- Installing: /usr/local/./include/SFML/System/String.hpp
-- Installing: /usr/local/./include/SFML/System/FileInputStream.hpp
-- Installing: /usr/local/./include/SFML/System/Utf.inl
-- Installing: /usr/local/./include/SFML/System/Lock.hpp
-- Installing: /usr/local/./include/SFML/System/Vector3.inl
-- Installing: /usr/local/./include/SFML/System/NonCopyable.hpp
-- Installing: /usr/local/./include/SFML/System/Clock.hpp
-- Installing: /usr/local/./include/SFML/System/Utf.hpp
-- Installing: /usr/local/./include/SFML/System/Thread.inl
-- Installing: /usr/local/./include/SFML/System/Vector2.hpp
-- Installing: /usr/local/./include/SFML/System/String.inl
-- Installing: /usr/local/./include/SFML/System/Err.hpp
-- Installing: /usr/local/./include/SFML/System/Sleep.hpp
-- Installing: /usr/local/./include/SFML/System/Export.hpp
-- Installing: /usr/local/./include/SFML/System/Thread.hpp
-- Installing: /usr/local/./include/SFML/OpenGL.hpp
-- Installing: /usr/local/./include/SFML/Config.hpp
-- Installing: /usr/local/./include/SFML/Graphics.hpp
-- Installing: /usr/local/./include/SFML/Audio
-- Installing: /usr/local/./include/SFML/Audio/SoundFileWriter.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundSource.hpp
-- Installing: /usr/local/./include/SFML/Audio/Listener.hpp
-- Installing: /usr/local/./include/SFML/Audio/Sound.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundBufferRecorder.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundFileReader.hpp
-- Installing: /usr/local/./include/SFML/Audio/InputSoundFile.hpp
-- Installing: /usr/local/./include/SFML/Audio/Music.hpp
-- Installing: /usr/local/./include/SFML/Audio/OutputSoundFile.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundStream.hpp
-- Installing: /usr/local/./include/SFML/Audio/AlResource.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundFileFactory.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundRecorder.hpp
-- Installing: /usr/local/./include/SFML/Audio/SoundFileFactory.inl
-- Installing: /usr/local/./include/SFML/Audio/SoundBuffer.hpp
-- Installing: /usr/local/./include/SFML/Audio/Export.hpp
-- Installing: /usr/local/./include/SFML/System.hpp
-- Installing: /usr/local/share/SFML/license.txt
-- Installing: /usr/local/share/SFML/readme.txt
-- Installing: /usr/local/share/SFML/cmake/Modules/FindSFML.cmake
-- Installing: /usr/local/lib/libsfml-system.so.2.3.2
-- Installing: /usr/local/lib/libsfml-system.so.2.3
-- Installing: /usr/local/lib/libsfml-system.so
-- Installing: /usr/local/lib/libsfml-window.so.2.3.2
-- Installing: /usr/local/lib/libsfml-window.so.2.3
-- Installing: /usr/local/lib/libsfml-window.so
-- Removed runtime path from "/usr/local/lib/libsfml-window.so.2.3.2"
-- Installing: /usr/local/lib/libsfml-network.so.2.3.2
-- Installing: /usr/local/lib/libsfml-network.so.2.3
-- Installing: /usr/local/lib/libsfml-network.so
-- Removed runtime path from "/usr/local/lib/libsfml-network.so.2.3.2"
-- Installing: /usr/local/lib/libsfml-graphics.so.2.3.2
-- Installing: /usr/local/lib/libsfml-graphics.so.2.3
-- Installing: /usr/local/lib/libsfml-graphics.so
-- Removed runtime path from "/usr/local/lib/libsfml-graphics.so.2.3.2"
-- Installing: /usr/local/lib/libsfml-audio.so.2.3.2
-- Installing: /usr/local/lib/libsfml-audio.so.2.3
-- Installing: /usr/local/lib/libsfml-audio.so
-- Removed runtime path from "/usr/local/lib/libsfml-audio.so.2.3.2"
Code is correct and libraries are correctly linked.
Code: https://github.com/paupav/boxGame
I'm usually using CodeBlocks
EDIT: it seems that I just have to define const strings instead of just writing in file names.
e.g
const std::string menuFS = "menu.ttf";
font.loadFromFile(menuFS);
instead of:
font.loadFromFile("menu.ttf");