0

I am try to compile the simple client/server code in GnuTLS, but a few errors of undefined reference.

$ gcc -o client client.o tcp.o `pkg-config gnutls --libs`
client.o: In function `main':
client.c:(.text+0x159): undefined reference to `gnutls_handshake_set_timeout'
client.o: In function `_verify_certificate_callback':
client.c:(.text+0x36a): undefined reference to `gnutls_certificate_verify_peers3'
client.c:(.text+0x3b1): undefined reference to `gnutls_certificate_verification_status_print'
collect2: ld returned 1 exit status

The result is the same if using "-lgnutls" option. Thanks a lot for the tip.

BTW, the sample code is located here (http://gnutls.org/manual/html_node/Client-examples.html).

user180574
  • 5,681
  • 13
  • 53
  • 94

1 Answers1

0

TFM has this to say about what to do if you want to compile a source file including the gnutls/gnutls.h header file:

gcc -o foo foo.c `pkg-config gnutls --cflags --libs`
ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • I guess something must be outdated and not well maintained, even the declaration of these functions are missing in gnutls.h. Previously I use "gcc" which does not complain until link (it may complain with proper options). But using "g++" will complain. – user180574 Oct 15 '13 at 00:34
  • Anyway, I am looking for sample code that uses "g_socket_client_connect_to_uri" along with TLS. If someone could provide a link, that would be really great! – user180574 Oct 15 '13 at 00:35