cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

linking error

Open Mamlesh opened this issue 7 years ago • 10 comments

shows linking error at compiling... "public: __cdecl web::uri::uri(wchar_t const *)" (??0uri@web@@QEAA@PEB_W@Z) referenced in function "void __cdecl `dynamic initializer for 'client''(void)" (??__Eclient@@YAXXZ) pls help...

Mamlesh avatar Apr 23 '18 10:04 Mamlesh

I suggest you provide the following information to allow anyone to help you:

  • specify what you're trying you build (cpprestsdk itself or a program using it)
  • what OS, compiler (including version) and platform (debug/ release, 32/64 bit, static/dynamic lib)
  • what release/version of cpprestsdk you have and e.g. whether you are using CMake (and which version)
  • whether you have customised any build options, or have specific local versions of dependencies (e.g. Boost)
  • and please provide the whole error message (not necessarily the whole compiler/ build output log, but at least a message with some context)

garethsb avatar Apr 23 '18 11:04 garethsb

  1. i want to use cpprestsdk in my program in which i am going to hit an API with 3 string parameters ...and what i'll get in return is Json string...
  2. OS windows x64 , Visual Studio 2015 version 14.0.24531.01 , .Net version 4.6.01055
  3. cpprestsdk v2.10.1
  4. ERROR..shows..

1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: __cdecl web::uri::uri(wchar_t const *)" (??0uri@web@@QEAA@PEB_W@Z) referenced in function "void __cdecl `dynamic initializer for 'client''(void)" (??__Eclient@@YAXXZ)

1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: __cdecl web::http::client::http_client::http_client(class web::uri const &)" (??0http_client@client@http@web@@QEAA@AEBVuri@3@@Z) referenced in function "void __cdecl `dynamic initializer for 'client''(void)" (??__Eclient@@YAXXZ)

1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: __cdecl web::http::client::http_client::~http_client(void)" (??1http_client@client@http@web@@QEAA@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'client''(void)" (??__Fclient@@YAXXZ)

when i use 'http_client client(L" ");' i got this error ....

Mamlesh avatar Apr 24 '18 05:04 Mamlesh

Thanks for the info. Is it successfully linking any symbols from the library? If you add /VERBOSE:LIB [1] to your linker command arguments can you see that it is actually searching the right library?

[1] https://msdn.microsoft.com/en-us/library/wdsk6as6.aspx

garethsb avatar Apr 24 '18 22:04 garethsb

thank you Sir for replay... this Verbose.lib shows me about the library i used in my code.... but i didn't find any library in downloaded Zip ... which i have to add in my code to resolve this error.... is their any lib file in clone downloaded cpprestsdk which i have to add in my code...

Mamlesh avatar Apr 25 '18 05:04 Mamlesh

C++ REST SDK is not a header-only library. You need to link to a DLL or static lib.

Depending on which download of C++ REST SDK you got, you probably have to build the library from source. I am not sure whether the documentation of How to build for Windows is up-to-date, but it's not complicated.

If you then install it in the default location, you'll then add e.g. "C:\Program Files\cpprest\lib\cpprest140_2_10.lib" to your program's linker dependencies.

Good luck.

garethsb avatar Apr 25 '18 08:04 garethsb

i install the cpprestsdk nuget package in Visual Studio (my project) ...but still face some unresolved external symbol error how can i resovle this error....

when i use "http_request" ...it gives error...

error LNK2001: unresolved external symbol "public: static class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const web::http::methods::POST" (?POST@methods@http@web@@2V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@B)

pls help...

Mamlesh avatar Apr 27 '18 06:04 Mamlesh

Did you try /VERBOSE:LIB as I mentioned previously?

garethsb avatar Apr 27 '18 07:04 garethsb

thank you for replay..Sir yes i try /VERBOSE:LIB ... it searching library which is used in the project ... now i install cpprestsdk 2.9.1 nuget package in my project ...now only one error comes ...when i used http_request...

Mamlesh avatar Apr 27 '18 08:04 Mamlesh

I got the same error when I tried to build the example Http Client Tutorial with Visual Studio (Windows 10). I installed this library as @garethsb-sony said. My code compiled but when I executed, I got the error of missing cpprest142_2_10d.dll. I added the directory "C:\Program Files (x86)\cpprestsdk\lib" on my Additional Library Directory, added "cpprest142_2_10d.lib" on the Additional Dependencies and I added the directory "C:\Program Files (x86)\cpprestsdk\bin" on the Executable Directories of my Visual Studio's project settings.

Visual studio console: 'BatchProcessManager.exe' (Win32): Loaded 'C:\Users\Gabriel\source\repos\BatchProcessManager\x64\Debug\BatchProcessManager.exe'. Symbols loaded. 'BatchProcessManager.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 'BatchProcessManager.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 'BatchProcessManager.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. The thread 0x3b6c has exited with code -1073741515 (0xc0000135). The thread 0x1468 has exited with code -1073741515 (0xc0000135). The program '[13552] BatchProcessManager.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.

My console output: (process 13552) exited with code -1073741515

Pls, help me! Thank you

gvalderramos avatar Dec 24 '19 00:12 gvalderramos

I had the same problem and the reason was that my configurations were not called "Debug" and "Release". Hope this helps.... 4 years on

BadJerry avatar Feb 22 '23 18:02 BadJerry