Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux上GCC中的编译错误_C_Gnutls - Fatal编程技术网

Linux上GCC中的编译错误

Linux上GCC中的编译错误,c,gnutls,C,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 `gnutl

我试图为编译代码,但编译时会出现以下错误

我已经检查了
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

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

您已要求gcc输出一个文件tls.o。通常*.o文件是已编译但未链接的目标文件。但默认情况下,gcc尝试链接其输入。如果您打算编译但尚未链接,请为gcc提供
-c
标志。