0

I'm trying to use the GnuTLS API on a window machine, sadly it will not work. I downloaded the latest precompiled version for Windows gnutls-3.3.9-w32.zip.

Each time I call a GnuTLS function, my program wont work probably. For testing there are only two lines of code:

printf ("hello");
gnutls_global_init();

it will build without errors but it won't print "hello", if I delete the second line it works. So there must be a mistake within the usage of GnuTLS.

I included the libgnutls-28.dll

gcc "-LC:GnuTLS\\gnutls-3.3.9-w32\\bin" -o Test.exe test.o -llibgnutls-28 

Do I have to link the libgnutls.dll.a file somehow?

guest123
  • 91
  • 3
  • 9

1 Answers1

0

Do I have to link the libgnutls.dll.a file somehow?.

Yes. Linking libraries is required for building. But you said it is building okay... In support of what Marc B was saying, test to see whether your printf is working:

printf ("hello");
getchar();                    // to stop execution before calling init  
//Check the return of your init function
status = gnutls_global_init();//On success, GNUTLS_E_SUCCESS (zero) is returned, 

For testing there are only two lines of code:
Add a few more to check status of your init function:

if(status < 0)                //otherwise an error code is returned.
{
     //handle error
} 

Click gnutls_global_init for man page.

Another thing to check is where you have the .dll located.

Ensure it is visible to the executable at run-time. Put it in either in the .exe. directory, or in the $SYSTEM$ directory, for your system.

One gottcha for people is WoW64. The Windows system directory for 32 bit applications on Windows 7 (or 8) is c:\windows\sysWoW64\ (i.e. not c:\windows\system32). Ironically, the system directory for 64 bit apps is c:\windows\system32\ .

ryyker
  • 22,849
  • 3
  • 43
  • 87
  • couldn't read out the status first, but thanks to your second tip with bad located .dlls I figuered out that appearently some .dlls have been missing. copyed them to the .exe directory and it finaly worked! Thanks! – guest123 Nov 12 '14 at 14:30