Can't statically link LexActivator

Hello,
I’m trying to test LexActivator on my c++ code on Windows. I use VisualStudio 2019.
I managed to dynamically link it, but I can’t do it statically, neither on the Sample.cpp I’ve downloaded from Cryptlex.
I followed the instructions:

  • I uncommented the block from line 6 to 18
  • In the forum I found that I should include all these additional dependencies:
    $(SolutionDir)x86\LexActivator.lib; $(SolutionDir)x86\libcurl_MD.lib; ws2_32.lib; Winhttp.lib; Shell32.lib

I always receive LNK2019 error messages:

Rebuild started...
------ Rebuild All started: Project: Sample, Configuration: Debug Win32 ------
Sample.cpp
D:\LicenseExample\Sample.cpp(178,16): warning C4244: 'initializing': conversion from 'time_t' to 'int', possible loss of data
D:\LicenseExample\Sample.cpp(209,17): warning C4244: 'initializing': conversion from 'time_t' to 'int', possible loss of data
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CertOpenStore@20 referenced in function _schannel_connect_step1
libcurl_MD.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp__CertOpenStore@20
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CertCloseStore@8 referenced in function _schannel_connect_step1
libcurl_MD.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp__CertCloseStore@8
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CertEnumCertificatesInStore@8 referenced in function _traverse_cert_store
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CertFindCertificateInStore@24 referenced in function _schannel_connect_step1
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateContext@4 referenced in function _pkp_pin_peer_pubkey
libcurl_MD.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp__CertFreeCertificateContext@4
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptStringToBinaryA@28 referenced in function _schannel_connect_step1
libcurl_MD.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp__PFXImportCertStore@12 referenced in function _schannel_connect_step1
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CryptDecodeObjectEx@32 referenced in function _cert_get_name_string
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertAddCertificateContextToStore@16 referenced in function _add_certs_to_store
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertFindExtension@12 referenced in function _cert_get_name_string
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertGetNameStringA@24 referenced in function _cert_get_name_string
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CryptQueryObject@44 referenced in function _add_certs_to_store
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertCreateCertificateChainEngine@8 referenced in function _Curl_verify_certificate
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateChainEngine@4 referenced in function _Curl_verify_certificate
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertGetCertificateChain@32 referenced in function _Curl_verify_certificate
libcurl_MD.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp__CertFreeCertificateChain@4 referenced in function _Curl_verify_certificate
D:\LicenseExample\Debug\Sample.exe : fatal error LNK1120: 16 unresolved externals
Done building project "Sample.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Any hint about how to solve it?

Hi,

LexActivator library now uses functions from a Windows library that it didn’t before. The old projects miss this dependency. So you will have to add crypt32.lib in your additional dependencies list as well.

Regards,
Ahmad.

Thank you Ahmad!
It works now.
But I switched to my project (x64 configuration) and I get some problems.
Here are the outputs:

LexActivator.lib(LexActivator.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexActivator.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexString.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexString.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexDataStore.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexDataStore.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexJsonParser.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexJsonParser.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexAbstraction.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexAbstraction.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexSystemInfo.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexSystemInfo.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexActivationService.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexActivationService.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexThread.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexThread.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexValidator.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexValidator.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexProductData.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexProductData.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexCrypter.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexCrypter.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexCrypto.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexCrypto.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexWmiClient.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexWmiClient.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexHttpClient.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexHttpClient.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexReleaseService.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexReleaseService.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexJwt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexJwt.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexBotan.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexBotan.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj
LexActivator.lib(LexLogger.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in EbClib.obj
LexActivator.lib(LexLogger.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in EbClib.obj

I found online that this kind of error may be related to runtime library choice.
I used /MDd option here. I tried all the other options (/MD /MT /MTd) but I only got more errors. Do you have any hint?

nannx

Hi,

Make sure when you build your project in a debug mode use LexActivatord.lib and libcurl_MDd/MTd.lib and for release mode use LexActivator.lib and libcurl_MD/MT.lib. You can also use macros(#ifdef) to make it easy for you to link for a specific build.

Thank you again,
I got it now and the project compiles!

Last question (I hope): why do I receive a list of warnings, like:

LexActivatord.lib(LexActivationService.obj) : warning LNK4099: PDB 'LexActivator.pdb' was not found with 'LexActivatord.lib(LexActivationService.obj)' or at 'D:\EbMnDosy_Outputs\Debug\LexActivator.pdb'; linking object as if no debug info
LexActivatord.lib(LexCrypto.obj) : warning LNK4099: PDB 'LexActivator.pdb' was not found with 'LexActivatord.lib(LexCrypto.obj)' or at 'D:\EbMnDosy_Outputs\Debug\LexActivator.pdb'; linking object as if no debug info
LexActivatord.lib(LexDataStore.obj) : warning LNK4099: PDB 'LexActivator.pdb' was not found with 'LexActivatord.lib(LexDataStore.obj)' or at 'D:\EbMnDosy_Outputs\Debug\LexActivator.pdb'; linking object as if no debug info

and so on, both in Debug and Release mode?
Thank you very much, Ahmad, you have been helpful!

nannx

Hi nannx,

Pleasure is all mine!

You can safely ignore these warnings. To know how to avoid such warnings please refer to the link below:

Regards,
Ahmad.