Hello there.
I am currently evaluating spine to be a core part of one of my projects and having a little trouble getting it to work properly.
I am using SFML 2.4.2 (intentional. I will upgrade to 2.5 later on.)
Here is the error:
[ 3%] Built target spine-sfml
[ 96%] Built target spine-cpp
[ 98%] Linking CXX executable DemoRPG
Undefined symbols for architecture x86_64:
"sf::CircleShape::CircleShape(float, unsigned long)", referenced from:
_main in main.cpp.o
"sf::VertexArray::clear()", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::VertexArray::append(sf::Vertex const&)", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::VertexArray::VertexArray(sf::PrimitiveType, unsigned long)", referenced from:
spine::SkeletonDrawable::SkeletonDrawable(spine::SkeletonData*, spine::AnimationStateData*) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::RenderStates::Default", referenced from:
_main in main.cpp.o
"sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)", referenced from:
_main in main.cpp.o
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::RenderTarget::clear(sf::Color const&)", referenced from:
_main in main.cpp.o
"sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in main.cpp.o
"sf::RenderWindow::~RenderWindow()", referenced from:
_main in main.cpp.o
"sf::Color::Green", referenced from:
_main in main.cpp.o
"sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)", referenced from:
_main in main.cpp.o
"sf::Shape::setFillColor(sf::Color const&)", referenced from:
_main in main.cpp.o
"sf::Shape::~Shape()", referenced from:
sf::CircleShape::~CircleShape() in main.cpp.o
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in main.cpp.o
"sf::Vertex::Vertex()", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Window::close()", referenced from:
_main in main.cpp.o
"sf::Window::display()", referenced from:
_main in main.cpp.o
"sf::Window::pollEvent(sf::Event&)", referenced from:
_main in main.cpp.o
"sf::Texture::setRepeated(bool)", referenced from:
spine::SFMLTextureLoader::load(spine::AtlasPage&, spine::String const&) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)", referenced from:
spine::SFMLTextureLoader::load(spine::AtlasPage&, spine::String const&) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Texture::setSmooth(bool)", referenced from:
spine::SFMLTextureLoader::load(spine::AtlasPage&, spine::String const&) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Texture::Texture()", referenced from:
spine::SFMLTextureLoader::load(spine::AtlasPage&, spine::String const&) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Texture::~Texture()", referenced from:
spine::SFMLTextureLoader::unload(void*) in libspine-sfml.a(spine-sfml.cpp.o)
"sf::BlendMode::BlendMode(sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation)", referenced from:
___cxx_global_var_init in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.1 in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.2 in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.3 in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.4 in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.5 in libspine-sfml.a(spine-sfml.cpp.o)
___cxx_global_var_init.6 in libspine-sfml.a(spine-sfml.cpp.o)
...
"sf::BlendMode::BlendMode()", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
_main in main.cpp.o
"sf::operator!=(sf::BlendMode const&, sf::BlendMode const&)", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
"sf::Window::isOpen() const", referenced from:
_main in main.cpp.o
"sf::Texture::getSize() const", referenced from:
spine::SkeletonDrawable::draw(sf::RenderTarget&, sf::RenderStates) const in libspine-sfml.a(spine-sfml.cpp.o)
spine::SFMLTextureLoader::load(spine::AtlasPage&, spine::String const&) in libspine-sfml.a(spine-sfml.cpp.o)
"typeinfo for spine::SpineObject", referenced from:
typeinfo for spine::String in main.cpp.o
typeinfo for spine::SkeletonClipping in libspine-sfml.a(spine-sfml.cpp.o)
typeinfo for spine::Color in libspine-sfml.a(spine-sfml.cpp.o)
typeinfo for spine::Vector<float> in libspine-sfml.a(spine-sfml.cpp.o)
typeinfo for spine::Vector<spine::Color> in libspine-sfml.a(spine-sfml.cpp.o)
typeinfo for spine::Vector<unsigned short> in libspine-sfml.a(spine-sfml.cpp.o)
"typeinfo for spine::TextureLoader", referenced from:
typeinfo for spine::SFMLTextureLoader in libspine-sfml.a(spine-sfml.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [DemoRPG] Error 1
make[2]: *** [CMakeFiles/DemoRPG.dir/all] Error 2
make[1]: *** [CMakeFiles/DemoRPG.dir/rule] Error 2
make: *** [DemoRPG] Error 2
Here is my folder structure: (In attachments)
And here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.13)
project(DemoRPG)
# includes the FindXXX.cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 17)
# OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
# SFML
find_package(SFML 2 REQUIRED audio graphics window system)
include_directories(${SFML_INCLUDE_DIR})
# SFML +2.5. Remove findSFML.cmake after upgrading
#find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
# Spine + Spine-SFML
set(SPINE_DIR vendor/spine-cpp/spine-cpp/)
set(SPINE_SFML_DIR vendor/spine-sfml/cpp)
add_subdirectory(vendor/spine-cpp)
add_subdirectory(vendor/spine-sfml/cpp)
include_directories(${SPINE_SFML_DIR}/src/)
include_directories(${SPINE_SFML_DIR}/include/)
include_directories(${SPINE_DIR}/src)
include_directories(${SPINE_DIR}/include)
file(GLOB SPINE_SFML_INCLUDES "${SPINE_SFML_DIR}/src/spine/*.h")
file(GLOB SPINE_SFML_SOURCES "${SPINE_SFML_DIR}/src/spine/*.cpp")
add_library(spine-sfml STATIC ${SPINE_SFML_INCLUDES} ${SPINE_SFML_SOURCES})
set(CMAKE_INCLUDE_PATH ${INCLUDE_DIR}:${SPINE_SFML_INCLUDES}:${SPINE_DIR}/include)
#add_library(spine STATIC ${SPINE_SFML_INCLUDES} ${SPINE_SFML_SOURCES})
add_executable(
DemoRPG
main.cpp
)
target_link_libraries(DemoRPG spine-cpp spine-sfml ${OPENGL_LIBRARIES})
I can also provide a MVP if it helps.