cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Minimal example fails to build in Visual Studio 2022 on Windows

Open symbolix opened this issue 4 months ago • 1 comments

Minimal example:

#include <iostream>
#include <cpprest/http_client.h>
#include <cpprest/ws_client.h>

int main()
{
    std::cout << "Hello World!\n";
    web::http::client::http_client httpClient(U("http://localhost"));
    web::websockets::client::websocket_client wsClient;
    (void)httpClient;
    (void)wsClient;
    return 0;
}

Error:

Build started at 20:01...
1>------ Build started: Project: restaurant-data-app, Configuration: Release x64 ------
1>restaurant-data-app.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl web::websockets::client::details::websocket_client_task_impl::websocket_client_task_impl(class web::websockets::client::websocket_client_config)" (__imp_??0websocket_client_task_impl@details@client@websockets@web@@QEAA@Vwebsocket_client_config@234@@Z)
1>C:\Users\me\dev\restaurant-data-app\x64\Release\restaurant-data-app.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "restaurant-data-app.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 20:01 and took 00.577 seconds ==========

symbolix avatar Sep 19 '25 19:09 symbolix

Apparently, websockets functionality has been removed without any notice or documentation update. This cost me a week trying to build a websocket client, and failing miserably! Only when I went back to baseline efb1e7436979a30c4d3e5ab2375fd8e2e461d541 in my vcpkg config, I managed to pull a version of cpprest that has a websocket functionality.

symbolix avatar Sep 27 '25 15:09 symbolix