3

I'm attempting to use cpprestsdk, to establish a simple websocket connection:

#include <cpprest/ws_client.h>
using namespace web;
using namespace web::websockets::client;

int main(int argc, char* argv[])
{
    websocket_callback_client client;
    client.connect(U("ws://localhost:1234")).then([]() { /* We've finished connecting. */ });
}

However, when I run the application I get error LNK2001: unresolved external symbol "public: __thiscall web::websockets::client::websocket_callback_client::websocket_callback_client(void)" (??0websocket_callback_client@client@websockets@web@@QAE@XZ)

I have included bcrypt.lib;winhttp.lib;crypt32.lib; in Linker, and also made reference to _NO_ASYNCRTIMP; in C/C++ -> Preprocessor, but I can't seem to escape this issue.

I can make simple http requests with the SDK it appears only websockets are causing the issue. I also installed this package using VCPKG and am using the Win32 build of the sdk.

Thanks, George

George Barlow
  • 155
  • 1
  • 5

1 Answers1

1

You need to install websockets feature:

.\vcpkg install cpprestsdk[websockets] --recurse
sibvic
  • 1,622
  • 2
  • 12
  • 19
  • Tank you! After hours of searching this solved my issue, could you please explain how this is different from a normal `vcpkg install cpprestsdk` command? – Battlechicken Jan 26 '21 at 22:55