You probably want your ‘flags’ field to be a ‘link_flags’ field.
Edit: actually that can’t be your issue because you appear to have built your main.exe. So I cannot really understand how you reached the point of dynamic link failure at run time. (I can’t really understand either how you got your main.exe build to complete with your link time dependencies specified in the ‘flags’ field.)
What you want to do is to link libssl and libcryptostatically. This means that you need to have libssl.a and libcrypto.a (which are the static versions of libssl.so and libcrypto.so) available in directory, say, dir and you want to pass -cclib -Ldir in the flag field so that the libraries can be found at link time.
[koji:sample_pj]$ dune build && sudo sh -c "sudo docker cp ./_build/default/bin/main.exe 0812956fe9e8:/tmp"
[koji:sample_pj]$ sudo docker exec 0812956fe9e8 ldd /tmp/main.exe
linux-vdso.so.1 (0x00007fff156a1000)
libssl.so.1.1 => not found
libcrypto.so.1.1 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f38925d4000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3892485000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f389247f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f389228d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3892c95000)
[koji:sample_pj]$
so i can build without error.
But yet libssl and libcrypto are not included…
My assumption is that libssl and libcrypto should not be included in the ldd results.
I epect a result like :
The compiler is probably choosing the shared library (.so) over the static one (.a).
You can try by using an explicit file name, as in -l:libssl.a -l:libcrypto.a instead of -lssl -lcrypto.