Reputation: 41
I am working on porting some proprietary software from OpenSSL 1.1.1 to OpenSSL 3.0.8, but I'm running into a problem. The application is multithreaded and written to compile under Visual Studio 2022.
The libraries I'm including are:
Comctl32.lib, libssl_static.lib, libcrypto_static.lib;crypt32.lib, ws2_32.lib, GDI32.LIB, ADVAPI32.LIB, USER32.LIB
The last three libraries are required, according to the OpenSSL documentation, when linking against the static libraries. Not including those three does NOT clear the warning or the error. I would seem to be missing a library that I need to include.
Depending on whether the static OpenSSL is happy with multithreaded applications, I should be able to ignore the warnings - although it would be better if I could avoid multiple copies of code. What I can't ignore are the errors.
The documentation for OpenSSL 3.0.8 states that it should be a simple migration from OpenSSL 1.1.1. Since it compiled against the static libraries with 1.1.1, I expected this to compile easily against the static libraries for 3.0.8.
I have tried compiling against the dynamic libraries for 3.0.8 and that works fine - it links and runs - but work has placed a requirement that the binary be statically compiled. This is what is producing the error.
Simply put, then, the libraries included are incorrect. There's a wrong version being used somewhere. Can someone help in figuring out what the library line should be?
The initial warnings (I've only included a few):
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4217: symbol '__time32' defined in 'libucrtd.lib(time.obj)' is imported by 'libcrypto_static.lib(libcrypto-lib-http_client.obj)' in function '_OSSL_HTTP_REQ_CTX_set_request_line' LINK : warning LNK4286: symbol '__time32' defined in 'libucrtd.lib(time.obj)' is imported by 'libcrypto_static.lib(libcrypto-lib-bss_conn.obj)' LINK : warning LNK4286: symbol '__time32' defined in 'libucrtd.lib(time.obj)' is imported by 'libcrypto_static.lib(libdefault-lib-drbg.obj)' LINK : warning LNK4217: symbol '__time32' defined in 'libucrtd.lib(time.obj)' is imported by 'libcrypto_static.lib(libcrypto-lib-bio_lib.obj)' in function '_BIO_do_connect_retry'
The errors I'm getting are:
1>libcrypto_static.lib(libcrypto-lib-params_from_text.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-dso_win32.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-asn1_lib.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-ctrl_params_translate.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-x509_obj.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-evp_key.obj) : error LNK2001: unresolved external symbol __imp__strncpy 1>libcrypto_static.lib(libcrypto-lib-pem_lib.obj) : error LNK2019: unresolved external symbol __imp__strspn referenced in function _PEM_get_EVP_CIPHER_INFO 1>libcrypto_static.lib(libcrypto-lib-v3_asid.obj) : error LNK2001: unresolved external symbol __imp__strspn 1>libcrypto_static.lib(libcrypto-lib-v3_addr.obj) : error LNK2001: unresolved external symbol __imp__strspn 1>libcrypto_static.lib(libcrypto-lib-bio_addr.obj) : error LNK2019: unresolved external symbol __imp__calloc referenced in function _WspiapiClone@8 1>libcrypto_static.lib(libcrypto-lib-conf_sap.obj) : error LNK2019: unresolved external symbol __imp___strdup referenced in function _OPENSSL_config 1>libcrypto_static.lib(libcrypto-lib-conf_lib.obj) : error LNK2001: unresolved external symbol __imp___strdup 1>libcrypto_static.lib(libcrypto-lib-bss_file.obj) : error LNK2019: unresolved external symbol __imp__feof referenced in function _file_ctrl 1>libcrypto_static.lib(libcrypto-lib-ui_openssl.obj) : error LNK2001: unresolved external symbol __imp__feof 1>libcrypto_static.lib(libcrypto-lib-bss_file.obj) : error LNK2019: unresolved external symbol __imp__ferror referenced in function _file_read 1>libcrypto_static.lib(libcrypto-lib-ui_openssl.obj) : error LNK2001: unresolved external symbol __imp__ferror 1>libcrypto_static.lib(libcrypto-lib-bss_file.obj) : error LNK2019: unresolved external symbol __imp__fgets referenced in function _file_gets 1>libcrypto_static.lib(libcrypto-lib-ui_openssl.obj) : error LNK2001: unresolved external symbol __imp__fgets 1>MSVCRT.lib(chandler4gs.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
Upvotes: 2
Views: 1078
Reputation: 29
Try using the /VERBOSE linker option to get more detailed information about the linker errors. This may help you identify which libraries are causing the problems.
reference - https://learn.microsoft.com/en-us/cpp/build/reference/verbose-print-progress-messages?view=msvc-170
Upvotes: 0