3

I want to use cpprestsdk as static library for my project, I used the vcpkg tool to get the static library by entering the command: vcpkg install cpprestsdk:x86-windows-static, I have the following lib files under my installed directory in vcpkg folder, I was wondering If I want to link my application to cpprestsdk I only need to link it with the resulting cpprest_2_10.lib? or I should add all the other libs?

enter image description here

Stephen Docy
  • 4,738
  • 7
  • 18
  • 31
Rathma
  • 1,196
  • 2
  • 33
  • 65
  • 1
    You need to add all the libs manually in proper dependency order. Use "vcpkg integrate install" to automatically insert the packages to your project. – seccpur Apr 09 '18 at 11:59
  • @seccpur the point is that I don't want to use `vcpkg`, How can I find the correct order? The purpose of static library is not removing to be dependent on multiple files? I guess that `cpprestsdk_2_10.lib` contains all the dependent libs ! Am I right? – Rathma Apr 09 '18 at 12:17
  • Unless it is not a big library, just put the independent libraries like boost and then higher up. For bigger open source projects ( like PCL ), just follow the installation order while vcpkg downloads and installs the package for you. – seccpur Apr 09 '18 at 12:24

1 Answers1

2

Yeah, you don't need all those libraries, mostly you just need cpprest_2_10.lib

I did the following with success: vcpkg install --triplet x64-windows-static-md cpprestsdk I then linked these files: zlib.lib cpprest_2_10.lib

I also learned, from this issue (https://github.com/Microsoft/vcpkg/issues/996) that you must also link to: crypt32.lib bcrypt.lib winhttp.lib

And use this preprocessor definition: _NO_ASYNCRTIMP=1

Jay Koutavas
  • 989
  • 1
  • 14
  • 28
  • Here is the x64-windows-static-md triplet I made: `set(VCPKG_TARGET_ARCHITECTURE x64)` `set(VCPKG_CRT_LINKAGE dynamic)` `set(VCPKG_LIBRARY_LINKAGE static)` `set(VCPKG_PLATFORM_TOOLSET v141)` – Jay Koutavas Apr 16 '18 at 15:10