liboqs
liboqs copied to clipboard
dlfcn required for windows build
Describe the bug
When building on windows receive a compile error from src/common/ossl_helpers.c - dlfcn.h is not available on windows
To Reproduce Try to build on windows :)
Expected behavior One of four things:
- Provide cross-platform code to load shared libraries (alternative to dlopen / dlclose)
- #ifdef around
#include <dlfcn.h>/ dlfcn functions (simply ignore on windows and assume that required libraries are loaded). - Require dlfcn-win32 package with basic instructions on the liboqs github page on how to install (prerequisite).
- Auto-install dlfcn-win32 from dlfcn-win32 github page as part of standard build.
Screenshots
I even put on a screenshot for you :)
Environment (please complete the following information):
- OS: Windows 11 with Visual Studio 2022 latest patches
- OpenSSL version: 3.3.0
- Compiler version used: MSVC (CL) 19.39.33523
- Build variables used: no overrides
- liboqs version: main branch
Additional context I added logs collected from my run which shows all the configuration occurring. buildliboqs.log''
I worked around the problem as follows:
// ABr: avoid dlfcn on windows
#if !defined(_MSC_VER)
#include <dlfcn.h>
#endif
[...]
static void ensure_symbol(const char *name, void **symp) {
#if !defined(_MSC_VER)
if (!*symp) {
void *sym = dlsym(libcrypto_dlhandle, name);
if (!sym) {
exit(EXIT_FAILURE);
}
*symp = sym;
}
#endif
}
static void ensure_library(void) {
#if !defined(_MSC_VER)
if (!libcrypto_dlhandle) {
libcrypto_dlhandle = dlopen(OQS_OPENSSL_CRYPTO_SONAME,
RTLD_LAZY | RTLD_LOCAL);
if (!libcrypto_dlhandle) {
exit(EXIT_FAILURE);
}
}
#define ENSURE_SYMBOL(name) \
ensure_symbol(#name, (void **)&_oqs_ossl_sym_##name)
#define FUNC(ret, name, args, cargs) \
ENSURE_SYMBOL(name);
#define VOID_FUNC FUNC
#include "ossl_functions.h"
#undef VOID_FUNC
#undef FUNC
#undef ENSURE_SYMBOL
#endif
}
Please check PLATFORMS.md: You'll notice limited Windows support for liboqs (we don't have people knowledgeable/interested in that platform for the project). Any contributions via PR welcome!
Just saw this. I'll be happy to put in some code as soon as I get to a stopping point.
On the good news - I have integrated all the defined NIST algos for DSA / KEM on Windows (with my local hacks for now), macOS, iOS, Android, and Linux (glibc 2.34 since a "static" openssl build...still requires a glibc unless yet-more-work is done with musl).
All my tests pass on every platform. I still need to prove interoperability such that when keys are exchanged between different platforms via PEM files that everything works. But so far things is looking good.