linking with openssl lib statically
Asked Answered
P

1

18

I've build openssl manually (static libraries) following this guide now when I try to link my MFC test app with libeay32.lib I get following errors:

1>Linking...
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _capi_free_key
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertGetCertificateContextProperty@16 referenced in function _capi_get_prov_info
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertOpenStore@20 referenced in function _capi_open_store
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertFindCertificateInStore@24 referenced in function _capi_find_cert
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertEnumCertificatesInStore@8 referenced in function _capi_find_cert
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertCloseStore@8 referenced in function _capi_find_key
1>libeay32.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp__CertDuplicateCertificateContext@4 referenced in function _capi_load_ssl_client_cert

Any advice? Thanks in advance.

EDIT: I’ve used OpenSSL 1.0.1t source code and Visual Studio 2008 command prompt for building 32 bit static libraries (I had no success with 1.0.2h version). My test app works fine when linking dynamically but I want to be able to link with static lib’s. I’m using OpenSSL for EVP Symmetric Encryption and Decryption

Progressive answered 30/5, 2016 at 9:53 Comment(0)
H
40

when I try to link my MFC test app with libeay32.lib I get following errors...

You need to configure with enable-capieng. Also see Compilation and Installation on the OpenSSL wiki and How to use CAPI engine in OpenSSL mailing list archive.

error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _capi_free_key 
...

Once configured properly, you need to link against Windows' crypt32.lib library. See, for example, CertFreeCertificateContext functions. On Windows, it should be enough to add the following to your MSVC source file:

#pragma comment (lib, "crypt32");
Hebdomadal answered 30/5, 2016 at 11:20 Comment(4)
Hi, thanks for replay, I’m a novice regarding openssl and can’t quite follow you I’m afraid. I’ve editet my question providing more info on my environment. I’ve did exactly as tutorial said for building the 32-bit static libraries and there were nothing mentioned for configuring with enable-capieng option? After I added #pragma comment (lib, "crypt32"); my app compiled and run but I'm getting memory leaks upon closing the appProgressive
@Progressive - OpenSSL is full of memory leaks. Its possible that your app is doing everything right yet still catching findings on them. However, before dismissing the memory leaks as internal OpenSSL problems, be sure to cleanup before shutdown. For that, see How to properly uninitialize OpenSSL.Hebdomadal
; at the end of #pragma is not neccessaryMisery
jww, Got the same problem. Your advice to enable crypt32.lib helped. But why does the boost documentation say nothing about the crypt32.lib ? How should I have guessed about including this file, if not your advice?Reachmedown

© 2022 - 2024 — McMap. All rights reserved.