LNK2019 errors when using Socket.IO classes.

So I’m attempting to link Socket.IO C++ Client to UE for connection purposes. I’m trying to follow these two setup guides GitHub - socketio/socket.io-client-cpp: C++11 implementation of Socket.IO client (for socket.io) and A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums,

so far, when in the VS editor, the Socket.IO classes show up with no problem. Even autocomplete seems to work properly. As soon as I build, I encounter the following errors:

Error 2 error LNK2019: unresolved external symbol “public: __cdecl sio::client::client(void)” (??0client@sio@@QEAA@XZ) referenced in function “public: __cdecl ATest::ATest(class FObjectInitializer const &)” (??0ATest@@QEAA@AEBVFObjectInitializer@@@Z) C:\Users\User\Documents\Unreal Projects\Cards\Intermediate\ProjectFiles\Test.cpp.obj Cards

Error 3 error LNK2019: unresolved external symbol “public: __cdecl sio::client::~client(void)” (??1client@sio@@QEAA@XZ) referenced in function “public: __cdecl std::unique_ptr<class sio::client,struct std::default_delete >::~unique_ptr<class sio::client,struct std::default_delete >(void)” (??1?$unique_ptr@Vclient@sio@@U?$default_delete@Vclient@sio@@@std@@@std@@QEAA@XZ) C:\Users\User\Documents\Unreal Projects\Cards\Intermediate\ProjectFiles\Test.cpp.obj Cards

Error 4 error LNK2001: unresolved external symbol “public: __cdecl sio::client::~client(void)” (??1client@sio@@QEAA@XZ) C:\Users\User\Documents\Unreal Projects\Cards\Intermediate\ProjectFiles\Cards.generated.cpp.obj Cards

Error 5 error LNK2019: unresolved external symbol “public: class std::shared_ptr const & __cdecl sio::client::socket(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (?socket@client@sio@@QEAAAEBV?$shared_ptr@Vsocket@sio@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@anonymous_user_e71e0d8a?$allocator@D@2@@4@@Z) referenced in function “public: __cdecl ATest::ATest(class FObjectInitializer const &)” (??0ATest@@QEAA@AEBVFObjectInitializer@@@Z) C:\Users\User\Documents\Unreal Projects\Cards\Intermediate\ProjectFiles\Test.cpp.obj Cards

Error 6 error LNK1120: 3 unresolved externals C:\Users\User\Documents\Unreal Projects\Cards\Binaries\Win64\UE4Editor-Cards.dll Cards

Error 7 error : Failed to produce item: C:\Users\User\Documents\Unreal Projects\Cards\Binaries\Win64\UE4Editor-Cards.dll C:\Users\User\Documents\Unreal Projects\Cards\Intermediate\ProjectFiles\ERROR Cards

Error 8 error MSB3073: The command ““C:\Program Files\Unreal Engine\4.7\Engine\Build\BatchFiles\Build.bat” CardsEditor Win64 Development “C:\Users\User\Documents\Unreal Projects\Cards\Cards.uproject” -rocket” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 Cards

I seem to be unable to access any of the sio::client class members. Does this mean I failed to link the library propery? Has anyone encountered a problem similar to this?

It means linker don’t see .lib files of Socket.IO in order to link your code to library, you did something wrong in build script. Also you are aware that UE4 got it’s own Socket API which you can use?

I see. I’m going to investigate if I can use FSocket client-side and Socket.IO server-side(is it possible?). Thanks for pointing this out.

FSocket is useful for networking UDP/TCP and other protocols.

Socket.IO uses Websockets or uses ajax if websocket is not avaliable. If you want to use FSocket you have to implement almost everything you need to use socket.io on server side…
I assume you want to use NopeJS, in this case i would recommend to keep going with c++ and Socket.IO.

Also the engine already has Websocket Support.

Well i didn’t know WebSocket has something more in to it, i just thouth is socket support for JS :stuck_out_tongue: On link you gave it only said engine libwebsocket, but there no proper UE4 APIs made which would use HTTP module and FSocket to work with it. I think cleanest implementation in UE4 would be use of HTTP module and FSocket if that possible, or even extend classes that they provide to make it work, From what i read websockets is normal socket communication just under HTTP server supervision.

Also on an ote ajax is JS APIs thing which allows to do extra HTTP requests on background

Update: I used another method to build the socket.io library(cmake then build solution : GitHub - socketio/socket.io-client-cpp: C++11 implementation of Socket.IO client). I had to build boost(one of the Socket.IO dependencies) for 64-bit before building the actual Socket.IO C++ lib, again for 64-bit. I then used the same steps for linking it according to A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums and it seems to be working now.

The Socket.IO uses multiple protocols it is different than the standard web-socket, It’s rather a wrapper. But all of them start with a single http request.