Using Photon Realtime with CRYENGINE

Hello all,

I'm just trying to use the Photon Realtime with CRYENGINE 5.4 and I'm using C++ API of both products.

I'm following the Realtime introduction and currently trying to implement my own listener from ExitGames::LoadBalancing::Listener.

The problem is, when I compile the project, I'm getting some LNK2019 linker errors which comes from Common::MemoryManagement::Internal::Interface. I've placed these full errors at the end of the post.

When I made some digging, I realized that malloc, free, realloc and calloc functions defined in MemoryManagement/Internal/Interface.h are mixed with the CRYENGINE defined macros, which are defined in exactly same names with Photon. (Currently, function names written in purple) For instance, for malloc function VS says "#define malloc CryModuleCRTMalloc"

So, I would like to hear some opinions about how to pass this problem.

Thanks in advance!

Compiler errors:
ComponentsPhoton_uber.obj : error LNK2019: unresolved external symbol "public: static void * __cdecl ExitGames::Common::MemoryManagement::Internal::Interface::CryModuleCRTMalloc(unsigned __int64)" ([email protected]@[email protected]@[email protected]@@[email protected]) referenced in function "public: class ExitGames::Common::JVector & __cdecl ExitGames::Common::JVector::operator=(class ExitGames::Common::JVector const &)" ([email protected]@[email protected]@@[email protected]@@Z)

ComponentsPhoton_uber.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ExitGames::Common::MemoryManagement::Internal::Interface::CryModuleCRTFree(void *)" ([email protected]@[email protected]@[email protected]@@[email protected]) referenced in function "public: virtual __cdecl ExitGames::Common::JVector::~JVector(void)" ([email protected]@[email protected]@@[email protected])


  • Well, I solved the compile problem with the following undefs. I'm not sure about the reliability but, we will see.

    #undef alloc
    #undef malloc
    #undef free
    #undef realloc
    #undef calloc
    #include "Photon-cpp/inc/PhotonPeer.h"
    #include "Common-cpp/inc/Common.h"
    #include "LoadBalancing-cpp/inc/Listener.h"
    #include "LoadBalancing-cpp/inc/Client.h"
  • Hi @Ozymandias.

    I am glad you found a solution and thanks for letting us know about this issue.

    If you include Photon headers before CryEngine headers, then you should not need to #undef those definitions as then the CryEngine code that defines them would be below the Photon code that needs them undefined.

    If you include the CryEngine headers, then undef those definitions and then include the Photon headers, then you should define them again (to the same values that they head before undefining them) after including the Photon headers or otherwise your own code that calls malloc() and co will now no longer use the CryEngine overrides of those functions, which might cause problems when exchanging memory that was allocated through these function between your code and CryEngine code. Also this might potentially affect performance.
  • Hi @Kaiserludi

    Thank you for the message. Honestly, I didn't define the undefs again and currently, I can communicate with the Photon network. Probably I will have a problem with the performance.

    I will definitely try to include Photon headers before CryEngine. That seems a more solid solution.

Sign In or Register to comment.