1

I finally linked Casablanca/CPPRESTSDK with VS17, thanks for this post Statically linking Casablanca/CPPREST SDK and some anothers. But now I see, that when I start project, for some reason VS automatically generates 3 DLL files zlib1.dll SSLEAY32.dll LIBEAY32.dll in folder with .exe, but I actually linked staticly for not to have them at all. I also have these files in lib format in vcpkg-master\installed\x86-windows-static\lib, can I somehow use them instead of dlls?

2
  • It seems that you want to statically link all of the cpprestsdk's dependencies, and dependencies of those dependencies recursively. Also note that files with .lib extension are not necessary static libraries, they can be import libraries for linking dlls. May 12, 2019 at 8:32
  • I just want to have 1 .exe file in my project, without any dll's.
    – Vlad Ross
    May 12, 2019 at 8:36

1 Answer 1

1

I had the same problem. I have a Visual Studio solution with projects using MFC in a shared DLL and using the multi-threaded DLL runtime library. I wanted to link statically to cpprestsdk without three extra DLLs to distribute. Linking to the static version of cpprestsdk wasn't working: I couldn't link because of conflicting runtime libraries (/MT - multithreaded and /MD - multi-threaded DLL). I couldn't find a pre-compiled version which used the /MD switch (multi-threaded DLL), but exported as a library. So I had to compile it myself.

My solution:

  • download vcpkg (https://github.com/microsoft/vcpkg). This is a package C and C++ library package manager. You will need to 'bootstrap' it. See the Quick Start.
  • install necessary dependencies for cpprestsdk: `vcpkg install --triplet x86-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli
  • download cpprestsdk from github (https://github.com/Microsoft/cpprestsdk)
  • generate a Visual Studio solution file (https://github.com/microsoft/cpprestsdk/wiki/How-to-build-for-Windows). I wanted to generate an x86 version, so I had to use the following command cmake ../Release -A win32 -DCMAKE_TOOLCHAIN_F ILE=d:\jw\git\vcpkg\scripts\buildsystems\vcpkg.cmake.
  • open cpprestsdk.sln solution and do the following for Release and Debug configurations in the cpprest project:
    • change the configuration type to Static library
    • change the target file extension to .lib.
    • build debug and release versions.

I could then use the generated libraries in my solution.

  • add the cpprestsdk include directory to my project
  • add the cpprestsdk libraries to the linker Input
  • add the zlib and openssl libraries from the cpprestsdk packages directory.
  • add the libraries bcrypt.lib, winhttp.lib and crypt32.lib to the linker Input too (Statically linking Casablanca/CPPREST SDK)
  • you also need to add the preprocessor flag _NO_ASYNCRTIMP to the project where you use cpprestsdk.

I hope this helps someone save some of the hours I lost getting it to work!

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.