netty-tcnative-openssl-static-2.0.28.Final-windows-x86_64.jar 动态链接到 openssl

netty-tcnative-openssl-static-2.0.28.Final-windows-x86_64.jar is dynamiclly linking to openssl

从源构建 netty-tcnative-openssl-static-2.0.28.Final-windows-x86_64 后,使用创建的 jar 文件导致运行时出现未解决的依赖错误:

Suppressed: java.lang.UnsatisfiedLinkError: AppData\Local\Temp\netty_tcnative2630860948705617016.dll: Can't find dependent libraries

这可能是由于 netty_tcnative.dll 依赖于 openssl dll:

dumpbin /dependents openssl-static\target\native-build\target\x64-release\lib\netty_tcnative.dll
Image has the following dependencies:

    libssl-1_1-x64.dll
    libcrypto-1_1-x64.dll
    KERNEL32.dll
    WS2_32.dll

知道为什么这些不会静态链接到 netty_tcnative.dll 吗?

构建是使用 Windows 10、x86 x64 Cross Tools Microsoft Visual Studio Professional 2015 完成的 版本 14.0.25420.01 更新 3

openssl 构建将导入库复制到目标目录

netty-tcnative\openssl-static\target\ssl\lib, 

不是静态库。这些是 tcnetty_native build 拾取的。

但是,静态库也是使用 openssl 构建创建的

netty-tcnative\openssl-static\target\openssl-1.1.1d\*_static.lib 

作为解决方法,将 _static.lib 版本复制到目标目录,替换 non_static 版本确实有所帮助。请注意,这还需要包含 msvcrt.lib 作为附加依赖项。在 netty-tcnative\vs2010.vcxproj.static.template:

<AdditionalDependencies>mswsock.lib;ws2_32.lib;rpcrt4.lib;shlwapi.lib;psapi.lib;apr-1.lib;msvcrt.lib;@SSL_LIBS@;%(AdditionalDependencies)</AdditionalDependencies>