Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error LNK2001: unresolved external symbol web::websockets::client::websocket_callback_client

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

like image 960
George Barlow Avatar asked Dec 18 '25 09:12

George Barlow


1 Answers

You need to install websockets feature:

.\vcpkg install cpprestsdk[websockets] --recurse
like image 105
sibvic Avatar answered Dec 21 '25 04:12

sibvic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!