From 50ae257a52065c222e0e57e19dad3eadb2333389 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Sun, 13 Dec 2015 00:28:00 -0600 Subject: [PATCH] fix VS 2015 openssl static link --- Crypto/include/Poco/Crypto/Crypto.h | 15 +++++++++++---- Crypto/include/Poco/Crypto/OpenSSLInitializer.h | 6 ++++++ Crypto/src/OpenSSLInitializer.cpp | 9 +++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Crypto/include/Poco/Crypto/Crypto.h b/Crypto/include/Poco/Crypto/Crypto.h index 1c62457d1..bcf0aa068 100644 --- a/Crypto/include/Poco/Crypto/Crypto.h +++ b/Crypto/include/Poco/Crypto/Crypto.h @@ -60,11 +60,18 @@ enum RSAPaddingMode // Crypto_API functions as being imported from a DLL, wheras this DLL sees symbols // defined with this macro as being exported. // -#if defined(_WIN32) && defined(POCO_DLL) - #if defined(Crypto_EXPORTS) - #define Crypto_API __declspec(dllexport) +#if defined(_WIN32) + #if defined(POCO_DLL) + #if defined(Crypto_EXPORTS) + #define Crypto_API __declspec(dllexport) + #else + #define Crypto_API __declspec(dllimport) + #endif #else - #define Crypto_API __declspec(dllimport) + #if (POCO_MSVS_VERSION >= 2015) // needed for OpenSSL + #pragma comment(lib, "legacy_stdio_definitions.lib") + #pragma comment(lib, "legacy_stdio_wide_specifiers.lib") + #endif #endif #endif diff --git a/Crypto/include/Poco/Crypto/OpenSSLInitializer.h b/Crypto/include/Poco/Crypto/OpenSSLInitializer.h index f647d3614..80ef41c91 100644 --- a/Crypto/include/Poco/Crypto/OpenSSLInitializer.h +++ b/Crypto/include/Poco/Crypto/OpenSSLInitializer.h @@ -122,4 +122,10 @@ inline void OpenSSLInitializer::disableSSLInitialization() } } // namespace Poco::Crypto +// needed for OpenSSL static link +#if defined(_WIN32) && !defined(POCO_DLL) && (POCO_MSVS_VERSION >= 2015) + extern "C" FILE * __cdecl __iob_func(void); +#endif + + #endif // Crypto_OpenSSLInitializer_INCLUDED diff --git a/Crypto/src/OpenSSLInitializer.cpp b/Crypto/src/OpenSSLInitializer.cpp index d76ca2f23..6dfe517c3 100644 --- a/Crypto/src/OpenSSLInitializer.cpp +++ b/Crypto/src/OpenSSLInitializer.cpp @@ -184,3 +184,12 @@ void uninitializeCrypto() } } // namespace Poco::Crypto + +// needed for OpenSSL static link +#if defined(_WIN32) && !defined(POCO_DLL) && (POCO_MSVS_VERSION >= 2015) + FILE * __cdecl __iob_func(void) + { + static FILE poco_iob[] = { stdin, stdout, stderr }; + return poco_iob; + } +#endif