Need help with OpenSSL static library

Michael Wojcik Michael.Wojcik at microfocus.com
Mon Mar 13 14:31:31 UTC 2023


> From: openssl-users <openssl-users-bounces at openssl.org> On Behalf Of Jonathan Day
> Sent: Monday, 13 March, 2023 06:16

> I've tried various options without much success

Tried various options how?

> I'm puzzled as to how fixing that would fix the errors (the missing functions), but it's possible Visual Studio
> is getting confused.

Visual Studio is an IDE; it makes this harder to resolve, because much of it is a black box, and much else is "simplified" to "help" you by not showing you what's actually going on. But Visual Studio is not the cause of the issue.

The problem is MSVC and its assortment of incompatible language runtimes.

Look at the messages from your original post:

> warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

Some objects were compiled with /MT and so have an embedded instruction to the linker to include MSVCRT.LIB when linking. That's the MSVC non-debug static C runtime 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'

Your link line is also using libucrtd.lib. The "d" suffix means this is a debug version of the static ("crt") MSVC runtime. So you're trying to link both non-debug and debug versions of the C runtime.

> libcrypto_static.lib(libcrypto-lib-params_from_text.obj) : error LNK2001: unresolved external symbol __imp__strncpy

__imp__strncpy is the strncpy from the dynamic MSVC C runtime, so apparently libcrypto-lib-params_from_text.obj was compiled with /MD or /MDd.

> If OpenSSL static is compiled with /MD or /MDd, is there any way to change the build script to compile it with /MT or /MTd?

Since you build it, you can do whatever you want to the build. But, yes, a quick check of 3.0.8 Configure and Configurations/* shows that configuring with "no-shared" should link with /MT.

-- 
Michael Wojcik


More information about the openssl-users mailing list