loaded_dypper
loaded_dypper

Reputation: 344

How to link OpenSSL in windows using MSYS2?

I wrote a c++ program using OpenSSL, it works fine on linux but when I try to compile on windows I get an error that libcrypto-1_1-x64.dll, libssl-1_1-x64.dll are missing

I am compiling using

 g++ main.cpp  -lws2_32 -LC:\msys64\mingw64\bin -IC:\msys64\mingw64\include\openssl

Both dll files can be found in C:\msys64\mingw64\bin, but the executable does not work

Upvotes: 0

Views: 1989

Answers (1)

Henrique Bucher
Henrique Bucher

Reputation: 4474

I just came up with a simple openssl example and compiled/linked fine

$ g++ ssltest.cpp  -lssl -lcrypto -o ssltest
$ ls -l
-rw-r--r-- 1 Fred None  1072 Aug 21 01:18 ssltest.cpp
-rwxr-xr-x 1 Fred None 77824 Aug 21 01:18 ssltest.exe

It just works out of the box. I am using the CLANG64 environment and I have the mingw-w64-clang-x86_64-openssl package installed. The files are installed on

$ pacman -Ql mingw-w64-clang-x86_64-openssl | grep '.dll'
mingw-w64-clang-x86_64-openssl /clang64/bin/libcrypto-1_1-x64.dll
mingw-w64-clang-x86_64-openssl /clang64/bin/libssl-1_1-x64.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/engines-1_1/capi.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/engines-1_1/padlock.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/libcrypto.dll.a
mingw-w64-clang-x86_64-openssl /clang64/lib/libssl.dll.a

Upvotes: 2

Related Questions