2

我正在尝试为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
4

1 回答 1

3

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

于 2011-03-04T21:19:00.830 回答