Tuesday, August 1, 2017

How to statically link the C++ REST SDK (Casablanca)

1 Download code
git clone https://github.com/Microsoft/cpprestsdk.git

2 Open solution in Visual Studio
cpprestsdk120.sln

   Change from dynamic to static linking
 
Select All Configurations and All Platforms from the drop-downs at the top of the Properties dialog.

In Configuration Properties -> General -> Project Defaults, change the Configuration Type option to Static library (.lib).

In Configuration Properties -> C/C++ -> Code Generation, change the Runtime Library option to Multi-threaded Debug (/MTd) for the Debug configuration and Multi-threaded (/MT) for the Release configuration.

In Configuration Properties -> C/C++ -> Preprocessor for All Configurations, add the text _NO_ASYNCRTIMP; to the Preprocessor Definitions option. This prevents the compiler from trying to export the functions to a DLL.

Click OK to save the changes.

3: Prepare your application

Open the solution for the application you want to build, right-click on it and choose Properties.

Select All Configurations and All Platforms from the drop-downs at the top of the Properties dialog.

In Configuration Properties -> VC++ Directories, add a new entry in Include Directories as follows:

C:\PathToCppRESTSDK\Release\include

In Configuration Properties -> VC++ Directories, add a new entry in Library Directories as follows:

C:\PathToCppRESTSDK\Binaries\Win32\$(Configuration)

In Configuration Properties -> C/C++ -> Preprocessor, add the text _NO_ASYNCRTIMP; to the Preprocessor Definitions option. This prevents the compiler from trying to find the C++ REST SDK functions from a DLL.

In Configuration Properties -> Linker -> Input, add winhttp.lib ,  Bcrypt.lib, Crypt32.lib and cpprest120_2_3.lib (replacing the numbers with the correct Visual Studio and C++ REST SDK version numbers) to the Additional Dependencies option.

Build your project.


https://katyscode.wordpress.com/2014/04/01/how-to-statically-link-the-c-rest-sdk-casablanca/

Change is missing 2  library.