SFML community forums
Help => Graphics => Topic started by: blueoyster on January 05, 2025, 10:08:02 pm
-
New to c++ and sfml,
Tried to implement my circle into a separate header and class file.
.draw() doesnt accept that my circle.shape is a drawable.
tho It seems to work with sf::RectangleShape.
I did the almost exact same wtith RectShape and that draws it no problem.
header file ; https://pastebin.com/n7enWda9
circle class: https://pastebin.com/Pq0cAXfn
main file (demo, essentially) : https://pastebin.com/mdDULJfQ
-
What's the full/complete error?
-
FAILED: _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj
C:\MinGW\bin\c++.exe -DSFML_STATIC -DSTBI_FAILURE_USERMSG -IC:/PATH/cmake-build-debug/_deps/sfml-src/include -IC:/PATH/cmake-build-debug/_deps/sfml-src/src -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/stb_image -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/glad/include -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/freetype2 -g -fdiagnostics-color=always -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wformat=2 -Wnull-dereference -Wold-style-cast -Wpedantic -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -MD -MT _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj -MF _deps\sfml-build\src\SFML\Graphics\CMakeFiles\sfml-graphics.dir\RenderTarget.cpp.obj.d -o _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj -c C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:46:0,
from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTexture.hpp:48:48: error: invalid use of incomplete type 'class sf::RenderTarget'
class SFML_GRAPHICS_API RenderTexture : public RenderTarget
^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:32:0,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Drawable.hpp:37:7: note: forward declaration of 'class sf::RenderTarget'
class RenderTarget;
^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:47:0,
from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderWindow.hpp:44:62: error: invalid use of incomplete type 'class sf::RenderTarget'
class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:32:0,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Drawable.hpp:37:7: note: forward declaration of 'class sf::RenderTarget'
class RenderTarget;
^~~~~~~~~~~~
C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp: In member function 'void sf::RenderTarget::draw(sf::RectangleShape, const sf::RenderStates&)':
C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:268:32: error: 'virtual void sf::Shape::draw(sf::RenderTarget&, sf::RenderStates) const' is private within this context
drawable.draw(*this, states);
^
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32:0,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:277:18: note: declared private here
virtual void draw(RenderTarget& target, RenderStates states) const;
^~~~
ninja: build stopped: subcommand failed.
-
It errors within the SFML headers. Hmm.
What's your version of MinGW that you're using?
-
gcc (MinGW.org GCC-6.3.0-1) 6.3.0
-
Yeah that's not a compatible compiler. For SFML 3 you need at least GCC 9.
Highly recommend to not use MinGW.org, that hasn't been updated in a decade or so.
The best source for GCC on Windows is either WinLibs (https://winlibs.com/) or MSYS2 (https://www.msys2.org/).
(The most recommended compiler on Windows is just MSVC and you can't go wrong with Visual Studio.)