Goal: build a windows binary that statically links libressl and doesn't require non-standard DLLs on windows
My info:
Host OS: MacOSX Catalina minGW version: 8.0.0 ( https://formulae.brew.sh/formula/mingw-w64 ) Code:
Code to compile:
import httpclient
var client = newHttpClient()
echo client.getContent("https://nim-lang.org")
Config.nims
switch("define", "noOpenSSLHacks")
switch("dynlibOverride", "ssl-")
switch("dynlibOverride", "crypto-")
#switch("passL", "/Users/user/Downloads/libressl-2.5.5-windows/x64/libcrypto-41.lib")
#switch ("passL", "/Users/user/Downloads/libressl-2.5.5-windows/x64/libssl-43.lib")
switch("define", "sslVersion:(")
switch("passL", "-static")
Compile
c -d:mingw -d:os=windows -d:ssl --passL:/Users/user/Downloads/libressl-2.5.5-windows/x64/libssl.lib --passL:/Users/user/Downloads/libressl-2.5.5-windows/x64/libcrypto.lib -d:release --passL:-Bstatic --passL:-Bdynamic test.nim
Reference: https://github.com/nim-lang/Nim/issues/15220 (I renamed the .libs and removed the version. Neither works) Libressl: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.5.5-windows.zip
The error:
Hint: [Link]
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: /Users/user/.cache/nim/test_r/stdlib_openssl.nim.c.o:stdlib_openssl.nim.c:(.text+0x15): undefined reference to `OPENSSL_init_ssl'
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: /Users/user/.cache/nim/test_r/stdlib_openssl.nim.c.o:stdlib_openssl.nim.c:(.text+0x41): undefined reference to `OpenSSL_version_num'
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: /Users/user/.cache/nim/test_r/stdlib_net.nim.c.o:stdlib_net.nim.c:(.text+0x1438): undefined reference to `SSL_CTX_set_ciphersuites'
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: /Users/user/.cache/nim/test_r/stdlib_net.nim.c.o:stdlib_net.nim.c:(.text+0x1b09): undefined reference to `SSL_in_init'
collect2: error: ld returned 1 exit status
Any advice? From my understanding, libressl can act as a drop-in replacement for openssl
Goal: build a windows binary that statically links libressl and doesn't require non-standard DLLs on windows
Goal: Learn the basics of Windows and DLLs.
Steps: Copy the required DLLs next to your .exe file. Ship a directory instead of a single file to your users.
Optional goal: Give your users a Windows installer.
Steps: Use the standard niminst tool to build an installer.
Success!
I don't want to install extra DLLs.
You don't have to "install" them at all.
As far as I know, .lib files are just stub used for dynamic linking with the dll (you can't "link" directly with a DLL on Windows, instead you either load it at runtime in your code or use the .lib stubs).
Static archives on Windows share the same .a suffix as *nix, however they are almost never used on Windows (since only MinGW supports them I assume). The way to go with Windows is usually DLLs, but if you really want to you can try to see if building LibreSSL with MinGW toolchain get you the .a you need.
In case you're wondering, choosenim is built with the OpenSSL binaries generated by the JuliaBinaryWrappers project, which was built with MinGW and features the necessary .a archives for static linking.