How to link Photon lib with Android project use Cmake?

I just upgrade cocos2dx to version 3.17.1 and use Cmake build game.
All is ok, except Photon lib.
I'm a newbie in cmake's world.

A part of CMakeLists.txt:
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
add_library(${APP_NAME} SHARED ${all_code_files})
target_include_directories(${APP_NAME} PRIVATE ${GAME_INC})
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
target_link_libraries(${APP_NAME} cocos2d)

When I try "target_link_libraries" to photon, I get error: undefined reference to 'std::ios_base::Init::Init()'

Can anyone help me?
Sorry for my English. Thanks!


  • Sorry. My mistake
  • Hi,
    Can you please help me,
    how to link Photon lib with Android project use Cmake.
  • Hi @Gammer.

    We use ndk-build and not cmake for building the Android libraries and demo projects.
    It should be possible to use cmake instead, but we don't have experience with doing so.
    Please see the demo projects for how to link the Photon libs with your Android project using ndk-build.
    Googles Android NDK documentation at should explain the differences between ndk-build and cmake and with the information you should be able to figure out how to translate a ndk-build makefile into a cmake makefile and vice versa.