Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Linking Against OpenSSL on Windows x86 #15

Open
mojomojomojo opened this issue May 18, 2022 · 0 comments
Open

Static Linking Against OpenSSL on Windows x86 #15

mojomojomojo opened this issue May 18, 2022 · 0 comments

Comments

@mojomojomojo
Copy link

I'm trying to build oatpp-openssl out of the box, statically linking against OpenSSL (1.1.1j).

git clone https://github.com/oatpp/oatpp-openssl.git
mkdir oatpp-openssl\build & cd oatpp-openssl\build
cmake .. -G "Visual Studio 15 2017" "-DCMAKE_PREFIX_PATH=c:\PATH\TO\OATPP_RUNTIME" "-DOPENSSL_ROOT_DIR=C:\PATH\TO\OPENSSL\openssl\static"
cmake --build . --config RelWithDebInfo

The build goes as expected until link time.

"C:\TEST_BUILD_DIR\oatpp-openssl\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj" (default target) (3) ->
(Link target) -> 
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertOpenStore@20 referenced in function _capi_open_store [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertCloseStore@8 referenced in function _capi_find_key [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertEnumCertificatesInStore@8 referenced in function _capi_find_cert [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFindCertificateInStore@24 referenced in function _capi_find_cert [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertDuplicateCertificateContext@4 referenced in function _capi_load_ssl_client_cert [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _capi_dsa_free [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertGetCertificateContextProperty@16 referenced in function _capi_cert_get_fname [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]
  C:\TEST_BUILD_DIR\oatpp-openssl\build\test\RelWithDebInfo\module-tests.exe : fatal error LNK1120: 7 unresolved externals [C:\TEST_BUILD_DIR\oatpp-openssl\build\test\module-tests.vcxproj]

These functions are defined (in Windows) in Crypt32.lib.

I can fix this issue on my system by

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aa10867..ca373ce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -38,6 +38,7 @@ target_include_directories(${OATPP_THIS_MODULE_NAME}
 target_link_libraries(${OATPP_THIS_MODULE_NAME}
         PUBLIC OpenSSL::SSL
         PUBLIC OpenSSL::Crypto
+        Crypt32
 )
 
 #######################################################################################################

However, I doubt that this is the correct solution, because it is likely only needed

  • on Windows
  • when linking statically against OpenSSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant