Spine::SkeletonAnimation

i am sorry for nonsense cause without any description. Ok, i am facing an error. Unresolved external symbols when i am trying to use spine::SkeletonAnimation::createWithJsonFile() and addAnimation function
I included <spine/spine-cocos2dx.h> in header file HelloWorldScene.h
I don’t know what i missed .Any help would be appreciated .

Which cocos2d-x version are you using? If you’re using v3.17.x or v4 with CMake, then show the contents of your CMakeLists.txt.

How have you added the Spine source files to your project? If you’re trying to use the Spine runtime that comes with cocos2d-x, then I suggest you don’t, and simply use the latest version from Esoteric Software.

there are two CMakeLists in my game folder, the one is in the same folder with Classes, Resources folder, ok the following is content of that CMakeLists
#/****************************************************************************

Copyright © 2013-2014 cocos2d-x.org

Copyright © 2015-2017 Chukong Technologies Inc.

http://www.cocos2d-x.org

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the “Software”), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in

all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

THE SOFTWARE.

****************************************************************************/

cmake_minimum_required(VERSION 3.6)

set(APP_NAME wp8Game_new)

project(${APP_NAME})

if(XCODE)
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
endif()
endif()

if(NOT DEFINED BUILD_ENGINE_DONE) # to test wp8Game_new into root project
set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

include(CocosBuildSet)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)

endif()

record sources, headers, resources…

set(GAME_SOURCE)
set(GAME_HEADER)

set(GAME_RES_FOLDER
“${CMAKE_CURRENT_SOURCE_DIR}/Resources”
)
if(APPLE OR WINDOWS)
cocos_mark_multi_resources(common_res_files RES_TO “Resources” FOLDERS ${GAME_RES_FOLDER})
endif()

add cross-platforms source files and header files

list(APPEND GAME_SOURCE
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
)
list(APPEND GAME_HEADER
Classes/AppDelegate.h
Classes/HelloWorldScene.h
)

if(ANDROID)
# change APP_NAME to the share library name for Android, it’s value depend on AndroidManifest.xml
set(APP_NAME MyGame)
list(APPEND GAME_SOURCE
proj.android/app/jni/hellocpp/main.cpp
)
elseif(LINUX)
list(APPEND GAME_SOURCE
proj.linux/main.cpp
)
elseif(WINDOWS)
list(APPEND GAME_HEADER
proj.win32/main.h
proj.win32/resource.h
)
list(APPEND GAME_SOURCE
proj.win32/main.cpp
proj.win32/game.rc
${common_res_files}
)
elseif(APPLE)
if(IOS)
list(APPEND GAME_HEADER
proj.ios_mac/ios/AppController.h
proj.ios_mac/ios/RootViewController.h
)
set(APP_UI_RES
proj.ios_mac/ios/LaunchScreen.storyboard
proj.ios_mac/ios/LaunchScreenBackground.png
proj.ios_mac/ios/Images.xcassets
)
list(APPEND GAME_SOURCE
proj.ios_mac/ios/main.m
proj.ios_mac/ios/AppController.mm
proj.ios_mac/ios/RootViewController.mm
proj.ios_mac/ios/Prefix.pch
${APP_UI_RES}
)
elseif(MACOSX)
set(APP_UI_RES
proj.ios_mac/mac/Icon.icns
proj.ios_mac/mac/Info.plist
)
list(APPEND GAME_SOURCE
proj.ios_mac/mac/main.cpp
proj.ios_mac/mac/Prefix.pch
${APP_UI_RES}
)
endif()
list(APPEND GAME_SOURCE ${common_res_files})
endif()

mark app complie info and libs info

set(all_code_files
${GAME_HEADER}
${GAME_SOURCE}
)
if(NOT ANDROID)
add_executable(${APP_NAME} ${all_code_files})
else()
add_library(${APP_NAME} SHARED ${all_code_files})
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
target_link_libraries(${APP_NAME} -Wl,–whole-archive cpp_android_spec -Wl,–no-whole-archive)
endif()

target_link_libraries(${APP_NAME} cocos2d)
target_include_directories(${APP_NAME}
PRIVATE Classes
PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
)

mark app resources

setup_cocos_app_config(${APP_NAME})
if(APPLE)
set_target_properties(${APP_NAME} PROPERTIES RESOURCE “${APP_UI_RES}”)

if(MACOSX)
    set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist")
elseif(IOS)
    set_xcode_property(${APP_NAME} INFOPLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist")
    set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
endif()

# For code-signing, set the DEVELOPMENT_TEAM:
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")

elseif(WINDOWS)
cocos_copy_target_dll(${APP_NAME})
endif()

if(LINUX OR WINDOWS)
cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
endif()

The left one is located in cocos2d\cocos\editor-support\spine . That file has contents:
set(COCOS_SPINE_HEADER
editor-support/spine/Animation.h
editor-support/spine/EventData.h
editor-support/spine/SkeletonAnimation.h
editor-support/spine/SlotData.h
editor-support/spine/SkeletonClipping.h
editor-support/spine/PathAttachment.h
editor-support/spine/PointAttachment.h
editor-support/spine/Event.h
editor-support/spine/Bone.h
editor-support/spine/Atlas.h
editor-support/spine/VertexAttachment.h
editor-support/spine/SkeletonRenderer.h
editor-support/spine/spine.h
editor-support/spine/ClippingAttachment.h
editor-support/spine/spine-cocos2dx.h
editor-support/spine/Color.h
editor-support/spine/Triangulator.h
editor-support/spine/RegionAttachment.h
editor-support/spine/Attachment.h
editor-support/spine/TransformConstraint.h
editor-support/spine/dll.h
editor-support/spine/SkeletonJson.h
editor-support/spine/IkConstraintData.h
editor-support/spine/AnimationStateData.h
editor-support/spine/kvec.h
editor-support/spine/Skeleton.h
editor-support/spine/Json.h
editor-support/spine/AttachmentLoader.h
editor-support/spine/Skin.h
editor-support/spine/VertexEffect.h
editor-support/spine/SkeletonBinary.h
editor-support/spine/SkeletonData.h
editor-support/spine/Array.h
editor-support/spine/PathConstraintData.h
editor-support/spine/SkeletonBatch.h
editor-support/spine/TransformConstraintData.h
editor-support/spine/Cocos2dAttachmentLoader.h
editor-support/spine/extension.h
editor-support/spine/PathConstraint.h
editor-support/spine/IkConstraint.h
editor-support/spine/BoundingBoxAttachment.h
editor-support/spine/AttachmentVertices.h
editor-support/spine/SkeletonTwoColorBatch.h
editor-support/spine/SkeletonBounds.h
editor-support/spine/Slot.h
editor-support/spine/BoneData.h
editor-support/spine/AnimationState.h
editor-support/spine/MeshAttachment.h
editor-support/spine/AtlasAttachmentLoader.h
)
set(COCOS_SPINE_SRC
editor-support/spine/Animation.c
editor-support/spine/AnimationState.c
editor-support/spine/AnimationStateData.c
editor-support/spine/Array.c
editor-support/spine/Atlas.c
editor-support/spine/AtlasAttachmentLoader.c
editor-support/spine/Attachment.c
editor-support/spine/AttachmentLoader.c
editor-support/spine/AttachmentVertices.cpp
editor-support/spine/Bone.c
editor-support/spine/BoneData.c
editor-support/spine/BoundingBoxAttachment.c
editor-support/spine/ClippingAttachment.c
editor-support/spine/Cocos2dAttachmentLoader.cpp
editor-support/spine/Color.c
editor-support/spine/Event.c
editor-support/spine/EventData.c
editor-support/spine/IkConstraint.c
editor-support/spine/IkConstraintData.c
editor-support/spine/Json.c
editor-support/spine/MeshAttachment.c
editor-support/spine/PathAttachment.c
editor-support/spine/PathConstraint.c
editor-support/spine/PathConstraintData.c
editor-support/spine/PointAttachment.c
editor-support/spine/RegionAttachment.c
editor-support/spine/Skeleton.c
editor-support/spine/SkeletonAnimation.cpp
editor-support/spine/SkeletonBatch.cpp
editor-support/spine/SkeletonBinary.c
editor-support/spine/SkeletonBounds.c
editor-support/spine/SkeletonClipping.c
editor-support/spine/SkeletonData.c
editor-support/spine/SkeletonJson.c
editor-support/spine/SkeletonRenderer.cpp
editor-support/spine/SkeletonTwoColorBatch.cpp
editor-support/spine/Skin.c
editor-support/spine/Slot.c
editor-support/spine/SlotData.c
editor-support/spine/TransformConstraint.c
editor-support/spine/TransformConstraintData.c
editor-support/spine/Triangulator.c
editor-support/spine/VertexAttachment.c
editor-support/spine/VertexEffect.c
editor-support/spine/extension.c
editor-support/spine/spine-cocos2dx.cpp
)

I am using ver4 by the way, i did’t add Spine source file to project. Yeah, you right, i am using spine that comes with cocos2d-x, i mean i create project by cmake, and spine folder is just there in my project, i didn’t do anything to have it. And can you show me how to use the latest version from Esoteric Software please?

Please format your post. Add 3 backtick characters before and after the code you pasted, because it is hard to read at the moment. You should also only include the relevant sections without the top copyright comment part.

There is no need to paste the contents of the CMakeLists.txt in the cocos2d-x engine folder. You only need to paste the contents of your own project CMakeLists.txt, which is in the root path of your project folder.

Edit your CMakeLists.txt so you don’t use the built-in Spine library:

cmake_minimum_required(VERSION 3.8)

set(APP_NAME gamename)

project(${APP_NAME})

set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

# add this line to disable the built-in Spine code
set(BUILD_EDITOR_SPINE OFF CACHE BOOL "Build editor support for spine" FORCE)

... other CMake content here, but once you get to this section:

target_link_libraries(${APP_NAME} PRIVATE cocos2d)
target_include_directories(${APP_NAME}
    PRIVATE Classes
    PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
)

# add spine
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spine ${PROJECT_BINARY_DIR}/spine)
get_target_property(spine_INCLUDE_DIRS spine-static INTERFACE_INCLUDE_DIRECTORIES)
target_link_libraries(${APP_NAME} PRIVATE spine-static)
target_include_directories(${APP_NAME}
	PRIVATE ${spine_INCLUDE_DIRS}
)

# spine cocos2d-x specific
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spine-cocos2dx ${PROJECT_BINARY_DIR}/spine-cocos2dx)
get_target_property(spine_cocos2dx_INCLUDE_DIRS spine-cocos2dx-static INTERFACE_INCLUDE_DIRECTORIES)
target_link_libraries(${APP_NAME} PRIVATE spine-cocos2dx-static)
target_include_directories(${APP_NAME}
	PRIVATE ${spine_cocos2dx_INCLUDE_DIRS}
)

... rest of the CMakeLists.txt content is here

This assumes you have the following folder structure (note the external folder that has the spine runtime code in it):
image

Get the latest Spine runtime code from https://github.com/EsotericSoftware/spine-runtimes/

This is the CMakeLists.txt for the spine-cocos2dx-static library:

get_target_property(COCOS2D_X_VERSION cocos2d VERSION)

if (COCOS2D_X_VERSION VERSION_GREATER_EQUAL 4.0)
	set(SPINE_COCOS_X_VERSION_DIR "v4")
else()
	set(SPINE_COCOS_X_VERSION_DIR "v3")
endif()

set(SPINE_COCOS2DX_HEADER
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AttachmentVertices.h
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonAnimation.h
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonRenderer.h
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/spine-cocos2dx.h
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/${SPINE_COCOS_X_VERSION_DIR}/SkeletonBatch.h
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/${SPINE_COCOS_X_VERSION_DIR}/SkeletonTwoColorBatch.h
   )

set(SPINE_COCOS2DX_SRC
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AttachmentVertices.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonAnimation.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonRenderer.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/spine-cocos2dx.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/${SPINE_COCOS_X_VERSION_DIR}/SkeletonBatch.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/${SPINE_COCOS_X_VERSION_DIR}/SkeletonTwoColorBatch.cpp
  )


list(APPEND SPINE_COCOS2DX_SRC ${SPINE_COCOS2DX_HEADER})

add_library(spine-cocos2dx-static STATIC ${SPINE_COCOS2DX_SRC})

set_target_properties(spine-cocos2dx-static
    PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)

add_dependencies(spine-cocos2dx-static spine-static cocos2d)

target_link_libraries(spine-cocos2dx-static 
	PUBLIC spine-static 
	PRIVATE cocos2d
)
target_include_directories(spine-cocos2dx-static 
    PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src
    PUBLIC ${CMAKE_CURRENT_LIST_DIR}/${SPINE_COCOS_X_VERSION_DIR}/src
    )

This CMakeLists.txt is for the spine-static library:

set(SPINE_HEADER
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Animation.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AnimationState.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AnimationStateData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Atlas.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AtlasAttachmentLoader.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Attachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AttachmentLoader.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AttachmentTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/AttachmentType.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/BlendMode.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Bone.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/BoneData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/BoundingBoxAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ClippingAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Color.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ColorTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ConstraintData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ContainerUtil.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/CurveTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Debug.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/DeformTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/dll.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/DrawOrderTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Event.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/EventData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/EventTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Extension.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/HashMap.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/HasRendererObject.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/IkConstraint.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/IkConstraintData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/IkConstraintTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Json.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/LinkedMesh.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/MathUtil.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/MeshAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/MixBlend.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/MixDirection.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathConstraint.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathConstraintData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathConstraintMixTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathConstraintPositionTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PathConstraintSpacingTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PointAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Pool.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/PositionMode.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/RegionAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/RotateMode.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/RotateTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/RTTI.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ScaleTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/ShearTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Skeleton.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SkeletonBinary.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SkeletonBounds.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SkeletonClipping.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SkeletonData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SkeletonJson.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Skin.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Slot.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SlotData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SpacingMode.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/spine.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SpineObject.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/SpineString.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TextureLoader.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Timeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TimelineType.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TransformConstraint.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TransformConstraintData.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TransformConstraintTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TransformMode.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TranslateTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Triangulator.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/TwoColorTimeline.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Updatable.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Vector.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/VertexAttachment.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/VertexEffect.h
    ${CMAKE_CURRENT_LIST_DIR}/include/spine/Vertices.h
    )

set(SPINE_SRC
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Animation.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AnimationState.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AnimationStateData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Atlas.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AtlasAttachmentLoader.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Attachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AttachmentLoader.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/AttachmentTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Bone.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/BoneData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/BoundingBoxAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/ClippingAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/ColorTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/ConstraintData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/CurveTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/DeformTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/DrawOrderTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Event.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/EventData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/EventTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Extension.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/IkConstraint.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/IkConstraintData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/IkConstraintTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Json.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/LinkedMesh.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/MathUtil.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/MeshAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathConstraint.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathConstraintData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathConstraintMixTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathConstraintPositionTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PathConstraintSpacingTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/PointAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/RegionAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/RotateTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/RTTI.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/ScaleTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/ShearTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Skeleton.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonBinary.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonBounds.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonClipping.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SkeletonJson.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Skin.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Slot.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SlotData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/SpineObject.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TextureLoader.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Timeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TransformConstraint.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TransformConstraintData.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TransformConstraintTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TranslateTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Triangulator.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/TwoColorTimeline.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/Updatable.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/VertexAttachment.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/spine/VertexEffect.cpp
    )

list(APPEND SPINE_SRC ${SPINE_HEADER})

add_library(spine-static STATIC ${SPINE_SRC})

set_target_properties(spine-static
    PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
target_include_directories(spine-static PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)

i am little confused which CMakeLists.txt is, cause there are two CMakeLists, the first one is located gameName/CMakeLists.txt
The second is located gameName/cocos2d/CMakeLists.txt
maybe it’s stupid question, hope that you can help me
Another question is : each time i create a project, do i have to do all things you’ve told me again and again? Cause i want to change in engine folder, so that every time i create a new one i don’t have to do that stuff again. I read https://docs.cocos2d-x.org/cocos2d-x/v4/en/advanced_topics/spine.html, is it way to do that?
I am so thankful for your time so far now. Cause i am a newbie, hope you can help me as much as you can.Very grateful.Thanks

That CMakeLists.txt belongs to the cocos2d source module, so don’t change anything in that. The only one you need to concern yourself with is the one located in the root folder of your game, gamename/CMakeLists.txt.

If you follow the method I showed you in my previous post, then for any new game project, you simply copy the external folder (with the spine and spine-cocos2dx runtimes in it), and just add the required lines into your CMakeLists.txt to build and link the spine runtimes.

I don’t recommend you use the method described in the docs, because it involves changing the cocos2d-x engine source and build files, so it’s too much messing around for no good reason.

That’s such an useful information. Thanks for clearing my mind.
do i make something wrongs ? I follow exactly your method. Here is first part code of CMakeLists.txt in the root path.


set(APP_NAME wp8Game_new)

project(${APP_NAME})

set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

# add this line to disable the built-in Spine code
set(BUILD_EDITOR_SPINE OFF CACHE BOOL "Build editor support for spine" FORCE)

target_link_libraries(${APP_NAME} PRIVATE cocos2d)
target_include_directories(${APP_NAME}
    PRIVATE Classes
    PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
)

# add spine
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spine ${PROJECT_BINARY_DIR}/spine)
get_target_property(spine_INCLUDE_DIRS spine-static INTERFACE_INCLUDE_DIRECTORIES)
target_link_libraries(${APP_NAME} PRIVATE spine-static)
target_include_directories(${APP_NAME}
	PRIVATE ${spine_INCLUDE_DIRS}
)

# spine cocos2d-x specific
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spine-cocos2dx ${PROJECT_BINARY_DIR}/spine-cocos2dx)
get_target_property(spine_cocos2dx_INCLUDE_DIRS spine-cocos2dx-static INTERFACE_INCLUDE_DIRECTORIES)
target_link_libraries(${APP_NAME} PRIVATE spine-cocos2dx-static)
target_include_directories(${APP_NAME}
	PRIVATE ${spine_cocos2dx_INCLUDE_DIRS}
)

if(XCODE)
    if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
        SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
    endif()
endif()
... and the rest code is below, i don't paste all here cause maybe it's not needed.

I created new CMakeLists.txt in folder spine, copy your code and paste into it, then i changed the contents of CMakeLists.txt in folder spine-cocos2d-x and replace with your code.
And i open my project, debug and the compiler gives me an error (cmd.exe exited with code 1).Things seem becoming complicated.

Attached to this post is a working test project with the spine runtimes and CMakeLists.txt updated, built using cocos2d-x v4.

The only thing that is missing is the cocos2d engine folder, so just copy one in when you want to build it. gamename_project.zip (2.5 MB)

Compare the CMakeLists.txt and the external folder to what you have, and I’m certain you’ll see what you’ve done differently.

ok. Thanks so much .i’ll check. Thanks for that file zip.

There is something missing in the code,
Here is problem:

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spine ${PROJECT_BINARY_DIR}/spine)
get_target_property(spine_INCLUDE_DIRS spine-static INTERFACE_INCLUDE_DIRECTORIES)
target_link_libraries(${APP_NAME} PRIVATE spine-static)
target_include_directories(${APP_NAME}
	PRIVATE ${spine_INCLUDE_DIRS}
) ```

In fact, my folder structure is gameName/cocos2d/external/spine. But the above code is just for gameName/external/spine so when i debug it gives me errors causing missing cocos2d I don't know how to code that cause i'm just a c++ programmer. Do you know how to fix that? Sorry for asking you so much today.

The files in the cocos2d/external/spine path are NOT the ones you want to use, so ignore the fact that they are there.

You literally have a test project that compiles and runs, so if there is something you do not understand, then refer to it.

Did you even take a look at the demo project? Did you look inside the gameName/external/ path? All you have to do is copy the external folder from that demo project into your own project root path.

I can’t help you more than that, because you have everything you need to get this working.

I’m not sure what you mean by that or what it has to do with this issue you’re having, but if there is something you don’t know, then it’s perhaps a good idea to learn it.

If you don’t know how CMake works, then read up on it; there’s plenty of info out there about it.

1 Like

ok i got it. Thanks man.

Dear.
I am facing an error again. That’s link fail, cause file lib between .h and .cpp is missing. Can you tell me where file lib is or how to get it ?
Really appreciate your help!

I’m not sure umm a lib between .h and .cpp

I have absolutely no idea what that means, and again, I posted a working project. Why don’t you compile that demo project, and if it doesn’t compile, then it’s something to do with your setup. If it does compile, then at least then you’ll be certain it’s your own project that has an issue, so you should be able to compare between the demo project and your own to figure out what differences there are.

I honestly can’t help you any more than that.

1 Like

i still get this error after all

I don’t know what you mean “a Lib between the .h and .cpp”.

I really respect your help. But your methods don’t work for my situation. I will wait for another method from every one .i can not fix this error myself,because this error comes from cocos2dx engine, i suppose. i am sure the error not from my code or my setup steps. Cause i followed guides from cocos2dx pages.

Cause as you see from the image i posted on top of this page, the compiler can not find SkeletionAniamtion.cpp. I did include spine/spine-cocos2dx.h in my header file. I did try method mentioned by R101, but it did not work. Any solution ? Thank for not ignoring my post.