On Tue, 26 Nov 2019 at 12:35, Stephen Leake <stephen_leake@stephe-leake.org> wrote:
> I'm trying to get list-packages to use https, which requires gnutls. I'm
> running Emacs master on mingw64.
>
> gnutls-available-p returns nil. Running emacs under the debugger, I can
> trace this to LoadLibraryW failing; the file name is
> L"libgnutls-30.dll", which is in PATH as
> D:\msys64\mingw64\bin\libgnutls-30.dll, installed via pacman.
>
> Currently neither w32_delayed_load nor init_gnutls_functions calls
> GetLastError; would it help to add that?
>
> Since the file should be found, it seems DllMain is returning False?
> What might be the reason for that?

Not a lot to go on here. Works just fine for me.

Are you missing a dependency? You can investigate DLL loading with <https://github.com/lucasg/Dependencies> (use it on libgnutls-30.dll, not on emacs.exe). Non-system dependencies here:

C:\msys64\mingw64\bin\libwinpthread-1.dll
C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
C:\msys64\mingw64\bin\libgmp-10.dll
C:\msys64\mingw64\bin\libhogweed-5.dll
C:\msys64\mingw64\bin\libidn2-0.dll
C:\msys64\mingw64\bin\libintl-8.dll
C:\msys64\mingw64\bin\libnettle-7.dll
C:\msys64\mingw64\bin\libp11-kit-0.dll
C:\msys64\mingw64\bin\libtasn1-6.dll
C:\msys64\mingw64\bin\libunistring-2.dll

It's unlikely, but is LoadLibrary finding a mismatched (32-bit) libgnutls-30.dll? It needn't be on PATH. <https://docs.microsoft.com/en-gb/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-desktop-applications>.

GnuTLS's DllMain (defined by the CRT) always returns true, but there is a library constructor which calls gnutls_global_init. You could look there for further clues. <https://gitlab.com/gnutls/gnutls/blob/master/lib/global.c>