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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Niidhogg

Pages: [1]
1
General / Re: Trying to compile an SFML test
« on: July 18, 2023, 11:26:58 pm »
No I was using wrong version of MinGW probably.
I made it work on CMake using the template you linked, thank you !

2
General / Trying to compile an SFML test
« on: July 18, 2023, 08:36:03 pm »
Hey,

I trying out SFML, but I got a problem at compilation, probably at linking.

I tried the example that's here: https://www.sfml-dev.org/tutorials/2.6/start-linux.php

I'm on Windows 10 but i'm using make and mingw.

Here is my makefile:
Quote
cpp_flags := -Wall -W -std=c++20
sfml_path := C:\SFML-2.6.0
sfml_include := $(sfml_path)\include
sfml_lib := $(sfml_path)\lib
sfml_modules := -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32

test.exe: bin/test.o
   g++ bin/test.o -o test.exe -L$(sfml_lib) $(sfml_modules) $(cpp_flags)

bin/test.o: src/test.cpp
   g++ -c src/test.cpp -o bin/test.o -DSFML_STATIC -I$(sfml_include)
These are some of the errors I get:
Quote
ld.lld: error: undefined symbol: sf::String::String(char const*, std::__1::locale const&)
>>> referenced by bin/test.o:(main)

ld.lld: error: undefined symbol: std::basic_ostream<char, std::char_traits<char>>& std::__ostream_insert<char, std::char_traits<char>>(std::basic_ostream<char, std::char_traits<char>>&, char const*, long long)
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::factorToGlConstant(sf::BlendMode::Factor))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced 227 more times

ld.lld: error: undefined symbol: std::ostream::put(char)
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::factorToGlConstant(sf::BlendMode::Factor))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced 123 more times

ld.lld: error: undefined symbol: std::ostream::flush()
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::factorToGlConstant(sf::BlendMode::Factor))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced by libsfml-graphics-s.a(RenderTarget.cpp.obj):((anonymous namespace)::RenderTargetImpl::equationToGlConstant(sf::BlendMode::Equation))
>>> referenced 122 more times
......................................

3
That helps, thx !

4
Hej !

I'm just working on a new project in SFML on Archlinux and everything went well, until I tried to load a Font. I don't really understanf why i get that error.

HW_Ressource.h
Quote
#ifndef HW_RESSOURCES_H
#define HW_RESSOURCES_H

#include <SFML/Graphics.hpp>

class HW_Ressources
{
   private:
      HW_Ressources();
      static sf::Font font_cantarell;
   
   public:
      static void load();
      static const sf::Font get_font_cantarell();
};

#endif

HW_Ressources.cpp

Quote
#include "HW_Ressources.h"

void HW_Ressources::load()
{
   sf::Font font;
   
   if(!font.loadFromFile("Cantarell-Regular.otf"))
      exit(EXIT_FAILURE);
   else HW_Ressources::font_cantarell = sf::Font(font);
}

const sf::Font HW_Ressources::get_font_cantarell()
{
   return HW_Ressources::font_cantarell;
}

COMPILING:

Quote
g++ -std=gnu++11 -Wall -Werror *.cpp -o exe -lsfml-graphics -lsfml-window -lsfml-system ; ./exe
/usr/bin/ld: /tmp/cciPHgtd.o: warning: relocation against `_ZN13HW_Ressources14font_cantarellE' in read-only section `.text'
/usr/bin/ld: /tmp/cciPHgtd.o: in function `HW_Ressources::load()':
HW_Ressources.cpp:(.text+0xc6): undefined reference to `HW_Ressources::font_cantarell'
/usr/bin/ld: /tmp/cciPHgtd.o: in function `HW_Ressources::get_font_cantarell()':
HW_Ressources.cpp:(.text+0x177): undefined reference to `HW_Ressources::font_cantarell'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
zsh: no such file or directory: ./exe

Pages: [1]
anything