COMPONENTS graphics audio REQUIRED)
find_package(Threads)
include_directories(${SFML_INCLUDE_DIR})
set(SFML_STATIC_LIBRARIES FALSE)
target_link_libraries(PitFall PUBLIC sfml-graphics sfml-audio Threads::Threads)
Вопрос, в чём тут проблема, что проект при попытке сборки выдаёт следующее?
Build Output :
[proc] Executing command: /usr/bin/cmake --build /home/d/Desktop/PitFall/build --config Debug --target PitFall -j 10 --
[build] [ 50%] Linking CXX executable PitFall
[build] /usr/bin/ld: CMakeFiles/PitFall.dir/PitFall.cpp.o: in function `main':
[build] /home/sakhil/Desktop/PitFall/PitFall.cpp:7: undefined reference to `Board::~Board()'
[build] /usr/bin/ld: CMakeFiles/PitFall.dir/PitFall.cpp.o: in function `Board::Board(unsigned long, unsigned long)':
[build] /home/d/Desktop/PitFall/Board.hpp:21: undefined reference to `Figure::Figure()'
[build] /usr/bin/ld: /home/d/Desktop/PitFall/Board.hpp:21: undefined reference to `vtable for Board'
[build] /usr/bin/ld: /home/d/Desktop/PitFall/Board.hpp:21: undefined reference to `Figure::~Figure()'
[build] collect2: error: ld returned 1 exit status
[build] make[3]: *** [CMakeFiles/PitFall.dir/build.make:88: PitFall] Error 1
[build] make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/PitFall.dir/all] Error 2
[build] make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/PitFall.dir/rule] Error 2
[build] make: *** [Makefile:118: PitFall] Error 2
[build] Build finished with exit code 2
[main] Failed to prepare executable target with name 'undefined'
Код из Board.hpp :
#ifndef BOARD_HPP
#define BOARD_HPP
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Shape.hpp>
class Figure
{
public:
Figure();
virtual ~Figure() = 0;
public:
virtual void draw(sf::RenderWindow& window) = 0;
virtual void setCoordinates(sf::Vector2f&) = 0;
};
class Board : public Figure
{
public:
Board(std::size_t x, std::size_t y) : _x{x}, _y{y} {}
virtual ~Board();
public:
void draw(sf::RenderWindow& window) override
{
window.draw(_board);
}
void setCoordinates(sf::Vector2f& coord) override
{
_x = coord.x;
_y = coord.y;
}
private:
sf::RectangleShape _board;
std::size_t _x, _y;
};
#endif /* BOARD_HPP */
main - коструктор board
Может кто помочь?
В cpp файле что лежит?
Уже подсказали, дурак не правильно сделал виртуальный деструктор и конструктор в классе
Обсуждают сегодня