Linux上GCC中的编译错误

时间:2011-03-04 21:16:12

标签: c gnutls

我正在尝试编译GnuTLS的代码,但在编译时会出现以下错误。

我已在gnutls.h的系统中检查/usr/include/gnutls/

原因还有什么?

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

1 个答案:

答案 0 :(得分:3)

这是一个链接错误。您需要包含一些带有-l标志的库。在不知道您的设置的情况下进行猜测,我会尝试-lgnutls