简体   繁体   English

Linux上GCC中的编译错误

[英]Compilation error in GCC on Linux

I am trying to compile my code for GnuTLS , but on compiling it gives the following errors. 我正在尝试为GnuTLS编译我的代码,但是在编译时会出现以下错误。

I have checked gnutls.h is present on my system in /usr/include/gnutls/ . 我已经检查了gnutls.h/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

This is a linking error. 这是一个链接错误。 You need to include some library with the -l flag. 您需要在-l标志中包含一些库。 Taking a wild guess without knowing your setup, I would try -lgnutls 在不知道您的设置的情况下进行疯狂的猜测,我会尝试-lgnutls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM