Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.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
如何在C++;项目 我试图在C++类中集成GNUTLS示例。 不幸的是,它在与g++链接时抛出未定义的引用。 因此,我尝试在不使用g++进行更改的情况下编译示例(纯C),但没有成功。 如果我使用gcc,它就会工作 tino@develeee:~/Code/tlstests$ gcc tlsclient.c -lgnutls /tmp/ccBqJdQr.o: In function `main': tlsclient.c:(.text+0x3d0): undefined reference to `tcp_connect' tlsclient.c:(.text+0x58d): undefined reference to `tcp_close' collect2: ld returned 1 exit status tino@develeee:~/Code/tlstests$ g++ tlsclient.c -lgnutls /tmp/ccRq5DcT.o: In function `load_keys()': tlsclient.c:(.text+0x186): undefined reference to gnutls_pcert_import_x509_raw(gnutls_pcert_st*, gnutls_datum_t const*, gnutls_x509_crt_fmt_t, unsigned int)' tlsclient.c:(.text+0x299): undefined reference to gnutls_privkey_init(gnutls_privkey_st**)' tlsclient.c:(.text+0x2b5): undefined reference to `gnutls_privkey_import_x509(gnutls_privkey_st*, gnutls_x509_privkey_int*, unsigned int)' /tmp/ccRq5DcT.o: In function `main': tlsclient.c:(.text+0x37e): undefined reference to `gnutls_certificate_set_retrieve_function2(gnutls_certificate_credentials_st*, int (*)(gnutls_session_int*, gnutls_datum_t const*, int, gnutls_pk_algorithm_t const*, int, gnutls_pcert_st**, unsigned int*, gnutls_privkey_st**))' tlsclient.c:(.text+0x3d6): undefined reference to `tcp_connect()' tlsclient.c:(.text+0x594): undefined reference to `tcp_close(int)' collect2: ld returned 1 exit status 你可以看到,在Gnuts/Exp文摘中声明的函数只有使用C++编译器才能被删除。(忽略对tcp_connect()和tcp_close()的未定义引用,它们只是没有定义和声明为extern) < C++是C +类和模板吗?所以我无法想象,为什么我会犯这些错误_C++_C_Linux_Gnu_Ssl - Fatal编程技术网

如何在C++;项目 我试图在C++类中集成GNUTLS示例。 不幸的是,它在与g++链接时抛出未定义的引用。 因此,我尝试在不使用g++进行更改的情况下编译示例(纯C),但没有成功。 如果我使用gcc,它就会工作 tino@develeee:~/Code/tlstests$ gcc tlsclient.c -lgnutls /tmp/ccBqJdQr.o: In function `main': tlsclient.c:(.text+0x3d0): undefined reference to `tcp_connect' tlsclient.c:(.text+0x58d): undefined reference to `tcp_close' collect2: ld returned 1 exit status tino@develeee:~/Code/tlstests$ g++ tlsclient.c -lgnutls /tmp/ccRq5DcT.o: In function `load_keys()': tlsclient.c:(.text+0x186): undefined reference to gnutls_pcert_import_x509_raw(gnutls_pcert_st*, gnutls_datum_t const*, gnutls_x509_crt_fmt_t, unsigned int)' tlsclient.c:(.text+0x299): undefined reference to gnutls_privkey_init(gnutls_privkey_st**)' tlsclient.c:(.text+0x2b5): undefined reference to `gnutls_privkey_import_x509(gnutls_privkey_st*, gnutls_x509_privkey_int*, unsigned int)' /tmp/ccRq5DcT.o: In function `main': tlsclient.c:(.text+0x37e): undefined reference to `gnutls_certificate_set_retrieve_function2(gnutls_certificate_credentials_st*, int (*)(gnutls_session_int*, gnutls_datum_t const*, int, gnutls_pk_algorithm_t const*, int, gnutls_pcert_st**, unsigned int*, gnutls_privkey_st**))' tlsclient.c:(.text+0x3d6): undefined reference to `tcp_connect()' tlsclient.c:(.text+0x594): undefined reference to `tcp_close(int)' collect2: ld returned 1 exit status 你可以看到,在Gnuts/Exp文摘中声明的函数只有使用C++编译器才能被删除。(忽略对tcp_connect()和tcp_close()的未定义引用,它们只是没有定义和声明为extern) < C++是C +类和模板吗?所以我无法想象,为什么我会犯这些错误

如何在C++;项目 我试图在C++类中集成GNUTLS示例。 不幸的是,它在与g++链接时抛出未定义的引用。 因此,我尝试在不使用g++进行更改的情况下编译示例(纯C),但没有成功。 如果我使用gcc,它就会工作 tino@develeee:~/Code/tlstests$ gcc tlsclient.c -lgnutls /tmp/ccBqJdQr.o: In function `main': tlsclient.c:(.text+0x3d0): undefined reference to `tcp_connect' tlsclient.c:(.text+0x58d): undefined reference to `tcp_close' collect2: ld returned 1 exit status tino@develeee:~/Code/tlstests$ g++ tlsclient.c -lgnutls /tmp/ccRq5DcT.o: In function `load_keys()': tlsclient.c:(.text+0x186): undefined reference to gnutls_pcert_import_x509_raw(gnutls_pcert_st*, gnutls_datum_t const*, gnutls_x509_crt_fmt_t, unsigned int)' tlsclient.c:(.text+0x299): undefined reference to gnutls_privkey_init(gnutls_privkey_st**)' tlsclient.c:(.text+0x2b5): undefined reference to `gnutls_privkey_import_x509(gnutls_privkey_st*, gnutls_x509_privkey_int*, unsigned int)' /tmp/ccRq5DcT.o: In function `main': tlsclient.c:(.text+0x37e): undefined reference to `gnutls_certificate_set_retrieve_function2(gnutls_certificate_credentials_st*, int (*)(gnutls_session_int*, gnutls_datum_t const*, int, gnutls_pk_algorithm_t const*, int, gnutls_pcert_st**, unsigned int*, gnutls_privkey_st**))' tlsclient.c:(.text+0x3d6): undefined reference to `tcp_connect()' tlsclient.c:(.text+0x594): undefined reference to `tcp_close(int)' collect2: ld returned 1 exit status 你可以看到,在Gnuts/Exp文摘中声明的函数只有使用C++编译器才能被删除。(忽略对tcp_connect()和tcp_close()的未定义引用,它们只是没有定义和声明为extern) < C++是C +类和模板吗?所以我无法想象,为什么我会犯这些错误,c++,c,linux,gnu,ssl,C++,C,Linux,Gnu,Ssl,以前有人有过这样的经历吗?在extern“C”{}块中包装您的标题。它看上去像Gnuts/Actudio.H./C> >作为C++头包含。将您的标题包在外“C”{} /代码>块中。它看起来像 Gnuts/Actudio。H/Obj>作为C++头包含。 < P>也似乎,作者也提供了C++接口。 #包括 > P>也显示,作者也提供了C++接口。 #包括 #include <gnutls/gnutlsxx.h>

以前有人有过这样的经历吗?

extern“C”{}
块中包装您的标题。它看上去像Gnuts/Actudio.H./C> >作为C++头包含。

将您的标题包在<代码>外“C”{} /代码>块中。它看起来像 Gnuts/Actudio。H/Obj>作为C++头包含。

< P>也似乎,作者也提供了C++接口。

#包括

> P>也显示,作者也提供了C++接口。

#包括
#include <gnutls/gnutlsxx.h>