2

I am trying to compile my code for GnuTLS, but on compiling it gives the following errors.

I have checked gnutls.h is present on my system in /usr/include/gnutls/.

What else can be the cause?

gcc -o tls.o tls.c  
/tmp/ccfyZ1Bd.o: In function `main':  
tls.c:(.text+0x1c): undefined reference to `gnutls_global_init'  
tls.c:(.text+0x28): undefined reference to `gnutls_anon_allocate_client_credentials'  
tls.c:(.text+0x3c): undefined reference to `gnutls_init'  
tls.c:(.text+0x58): undefined reference to `gnutls_priority_set_direct'  
tls.c:(.text+0x74): undefined reference to `gnutls_credentials_set'  
tls.c:(.text+0x79): undefined reference to `tcp_connect'  
tls.c:(.text+0x91): undefined reference to `gnutls_transport_set_ptr'  
tls.c:(.text+0x9d): undefined reference to `gnutls_handshake'
tls.c:(.text+0xdc): undefined reference to `gnutls_perror'  
tls.c:(.text+0x109): undefined reference to `gnutls_record_send'  
tls.c:(.text+0x125): undefined reference to `gnutls_record_recv'  
tls.c:(.text+0x154): undefined reference to `gnutls_strerror'  
tls.c:(.text+0x1e6): undefined reference to `gnutls_bye'  
tls.c:(.text+0x1f2): undefined reference to `tcp_close'  
tls.c:(.text+0x1fe): undefined reference to `gnutls_deinit'  
tls.c:(.text+0x20a): undefined reference to `gnutls_anon_free_client_credentials'  
tls.c:(.text+0x20f): undefined reference to `gnutls_global_deinit'  
collect2: ld returned 1 exit status
user2428118
  • 7,935
  • 4
  • 45
  • 72
tarun
  • 41
  • 1
  • 2
  • 2
    You have asked gcc to output a file tls.o. Usually *.o files are object files which have been compiled but not linked. But by default, gcc tries to link its input. If you meant to compile but not yet link, give gcc the `-c` flag. – aschepler Mar 04 '11 at 21:22

1 Answers1

3

This is a linking error. You need to include some library with the -l flag. Taking a wild guess without knowing your setup, I would try -lgnutls

Null Set
  • 5,374
  • 24
  • 37