How to Include OpenSSL in Visual Studio
Introduction
This guide applies to any OpenSSL version and any Visual Studio version.
Prerequisites
Ensure you have OpenSSL installed. The precompiled installer for Windows includes the necessary libraries.
Configuring the Compiler
- In "Project Properties" under "C/C " and "General," add the OpenSSL include directory to "Additional Include Directories." This typically resembles:
"C:Program FilesOpenssl-Win32-1.0.1p.....include"
Configuring the Linker
- Under "Project Properties" > "Linker" > "General" > "Additional Library Directories," add the OpenSSL library directory. This typically looks like:
"C:Program FilesOpenssl-Win32-1.0.1p.....lib"
-
Under "Project Properties" > "Linker" > "Input" > "Additional Dependencies," include the required OpenSSL libraries:
- libcrypto-1_(-x64).lib (for versions 1.1.) or libeay32.lib (for older versions)
- libssl-1_(-x64).lib (for versions 1.1.) or ssleay32.lib (for older versions)
Note: _static versions are available but may not be necessary.
Building and Running
- Build the project.
- Ensure the OpenSSL library dependencies are located in the PATH environment variable, in the executable's folder, or in a directory included in the PATH.
Example Include
In your code, include the OpenSSL header file as follows:
#include <openssl/ssl.h>
Copy after login
Conclusion
By following these steps, you can incorporate OpenSSL into your Visual Studio projects, enabling you to work with SSL/TLS protocols and encryption operations.
The above is the detailed content of How to Integrate OpenSSL into Visual Studio Projects?. For more information, please follow other related articles on the PHP Chinese website!