
Expanding Cross-Compilation Capabilities in Visual Studio
With the recent release of wolfSSL, we have significantly improved the cross-compiling capabilities of wolfSSL in Visual Studio, particularly when targeting non-Windows operating systems from a Windows-based development environment. This improvement was introduced in PR #7884 and provides a new build option that makes cross-compilation smoother and more efficient.
Introducing WOLFSSL_NOT_WINDOWS_API
One of the key additions in this release is the new macro WOLFSSL_NOT_WINDOWS_API
. This is specifically designed for scenarios where:
- The compilation is performed on Windows using Visual Studio.
- The target operating system is not Windows.
- The Windows API should not be used during compilation.
When WOLFSSL_NOT_WINDOWS_API
is defined, the related macro USE_WINDOWS_API
is not defined, ensuring that wolfSSL is built under the assumption that no Windows API functions are available. This allows developers to cross-compile for platforms such as Linux or embedded systems while using Visual Studio as their primary development environment.
Why is this Important?
In many embedded and IoT use cases, developers prefer to work within Visual Studio due to its powerful debugging and development tools. However, the final deployment target may be a non-Windows OS. Prior to this update, Visual Studio builds often assumed that Windows API functions were available, leading to compatibility issues when targeting platforms that do not support them.
With WOLFSSL_NOT_WINDOWS_API
, these limitations are removed, making it much easier to:
- Compile wolfSSL for embedded Linux and other POSIX-based environments from Windows.
- Maintain a single development workflow without switching between build environments.
- Ensure consistent behavior across different platforms.
How to Use WOLFSSL_NOT_WINDOWS_API
in Your Build
To leverage this new macro, follow these steps:
-
Modify Your Preprocessor Definitions:
In your Visual Studio project settings, navigate to:
- Configuration Properties → C/C++ → Preprocessor → Preprocessor Definitions
- Add
WOLFSSL_NOT_WINDOWS_API
to the list.
-
Use CMake (if applicable):
If you are using CMake for your build configuration, you can define this macro using:
add_definitions(-DWOLFSSL_NOT_WINDOWS_API)
- Manually Define in Your Code (not recommended):
You can also define the macro at the beginning of your source files, though this is not the preferred method:
#define WOLFSSL_NOT_WINDOWS_API
#include
#include
Example Use Case: Building wolfSSL for Linux from Visual Studio
Let’s say you want to compile wolfSSL in Visual Studio for a Linux-based target while avoiding Windows API dependencies. Here’s a step-by-step approach:
- Set Up Your Toolchain
Install a cross-compilation toolchain for Linux, such as MinGW-w64 or WSL with a Linux cross-compiler.
- Update Your Visual Studio Project Settings
- Define
WOLFSSL_NOT_WINDOWS_API
in preprocessor definitions.
- Ensure that your include paths point to the correct non-Windows headers.
- Compile and Verify
- Build the project in Visual Studio.
- Test the generated binary on the target Linux system to ensure it operates correctly.
Future Enhancements and Next Steps
This update is just the beginning of improving wolfSSL’s cross-compilation capabilities within Visual Studio. Some potential future enhancements include:
- Better integration with CMake toolchains for automated cross-platform builds.
- Expanded CI/CD support for Visual Studio-based cross-compilation.
- Additional optimizations to streamline the build process further.
Conclusion
With the introduction of WOLFSSL_NOT_WINDOWS_API
, developers can now cross-compile wolfSSL in Visual Studio for non-Windows targets without encountering Windows API dependencies. This simplifies the workflow for embedded and Linux developers who prefer to work in Visual Studio but deploy on other platforms.
For more details on getting started with wolfSSL in Visual Studio, check out our previous blog: Getting Started with wolfSSL Using Visual Studio 2022
Or this awesome webinar recording on YouTube.

Have a specific request or questions? We’d love to hear from you. Please contact us at support@wolfSSL.com or open an issue on GitHub.
If you have questions about any of the above, please contact us at facts@wolfSSL.com or +1 425 245 8247.
Download wolfSSL Now