X Tutup
The Wayback Machine - https://web.archive.org/web/20201201003716/https://github.com/microsoft/cpprestsdk/issues/1495
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket library link error with vcpkg install #1495

Open
foobra opened this issue Sep 4, 2020 · 2 comments
Open

websocket library link error with vcpkg install #1495

foobra opened this issue Sep 4, 2020 · 2 comments

Comments

@foobra
Copy link

@foobra foobra commented Sep 4, 2020

I've install cpprestsdk with vcpkg, and executed vcpkg.exe integrate install.
But when I #include <cpprestsdk/ws_client.h> in visual studio 2019, It has some link error.

Error | LNK2019 | unresolved external symbol "__declspec(dllimport) public: class Concurrency::task<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __cdecl web::websockets::client::websocket_incoming_message::extract_string(void)const " (__imp_?extract_string@websocket_incoming_message@client@websockets@web@@QEBA?AV?$task@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Concurrency@@XZ) referenced in function "public: void __cdecl <lambda_d084fb8f680c72cb130d66a02d9b5b24>::operator()(class web::websockets::client::websocket_incoming_message)const " (??R<lambda_d084fb8f680c72cb130d66a02d9b5b24>@@QEBAXVwebsocket_incoming_message@client@websockets@web@@@Z)

Error | LNK2019 | unresolved external symbol "__declspec(dllimport) public: class Concurrency::task<class web::websockets::client::websocket_incoming_message> __cdecl web::websockets::client::details::websocket_client_task_impl::receive(void)" (__imp_?receive@websocket_client_task_impl@details@client@websockets@web@@QEAA?AV?$task@Vwebsocket_incoming_message@client@websockets@web@@@Concurrency@@XZ) referenced in function "public: class Concurrency::task<class web::websockets::client::websocket_incoming_message> __cdecl web::websockets::client::websocket_client::receive(void)" (?receive@websocket_client@client@websockets@web@@QEAA?AV?$task@Vwebsocket_incoming_message@client@websockets@web@@@Concurrency@@XZ)

Error | LNK2019 | unresolved external symbol "__declspec(dllimport) public: void __cdecl web::websockets::client::details::websocket_client_task_impl::close_pending_tasks_with_error(class web::websockets::client::websocket_exception const &)" (__imp_?close_pending_tasks_with_error@websocket_client_task_impl@details@client@websockets@web@@QEAAXAEBVwebsocket_exception@345@@Z) referenced in function __catch$??R<lambda_c8bcff768c1b7a6664919177f490ce2a>@@QEBAXV?$task@X@Concurrency@@@Z$0

Error | LNK2019 | 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) referenced in function "void __cdecl std::_Construct_in_place<class web::websockets::client::details::websocket_client_task_impl,class web::websockets::client::websocket_client_config>(class web::websockets::client::details::websocket_client_task_impl &,class web::websockets::client::websocket_client_config &&)" (??$_Construct_in_place@Vwebsocket_client_task_impl@details@client@websockets@web@@Vwebsocket_client_config@345@@std@@YAXAEAVwebsocket_client_task_impl@details@client@websockets@web@@$$QEAVwebsocket_client_config@345@@Z)

Here is my sample codes:

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

int main(int argc, const char * argv[]) {
// insert code here...
websocket_client_config config;
config.headers().add(U("Sec-WebSocket-Protocol"), "protoo");
websocket_client client(config);
std::string body_str("hello");

     try
     {
         client.connect(U("wss://echo.websockets.org")).wait();
         auto receive_task = client.receive().then([body_str](websocket_incoming_message ret_msg) {

             auto ret_str = ret_msg.extract_string().get();

         });

         websocket_outgoing_message msg;
         msg.set_utf8_message(body_str);
         client.send(msg).wait();

         receive_task.wait();
         client.close().wait();
     }
     catch (const websocket_exception& e)
     {
       printf("%s", e.what());
         throw;
     }

return 0;
}

@barcharcraz
Copy link
Contributor

@barcharcraz barcharcraz commented Sep 16, 2020

can you post your build system? Are you using msbuild or cmake?

@foobra
Copy link
Author

@foobra foobra commented Sep 17, 2020

can you post your build system? Are you using msbuild or cmake?

I use cmake with add_library() to include library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup