我在 Ubuntu 14.04 中预装了 openssl 版本
OpenSSL 1.0.1f 6 Jan 2014
这是 Ubuntu 中可用的最新版本。现在的问题是在我编译它显示的代码时SSL_library_init();
调用了它:DTLSv1_2_client_method();
DTLS_test.c:20:12: warning: assignment makes pointer from integer without a cast [enabled by default]
method = DTLSv1_2_client_method();
^
/tmp/ccRUlnEu.o: In function `init_lib':
DTLS_test.c:(.text+0x13): undefined reference to `DTLSv1_2_client_method'
collect2: error: ld returned 1 exit status
但是如果我改为method = DTLSv1_client_method();
它只显示与演员表相关的警告
DTLS_test.c:20:12: warning: assignment makes pointer from integer without a cast [enabled by default]
method = DTLSv1_2_client_method();
^
代码片段如下:
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/dtls1.h>
#include "DTLS_test.h"
void init_lib (void) {
if(SSL_library_init()) {
printf("\n[OK] SSL library initialized");
}
else {
printf("\n[ERROR] SSL library initiate FAILED !");
exit(0);
}
SSL_METHOD *method = NULL;
method = DTLSv1_2_client_method();
SSL_CTX *ctx = NULL;
ctx = SSL_CTX_new(method);
if(ctx != NULL) {
printf("\n[OK] SSL Method created");
}
else {
printf("\n[ERROR] SSL Method FAILED !");
exit(0);
}
}
void main (void) {
init_lib ();
printf("\n");
}
我也从 git 下载了 openssl 源代码并安装了,但 openssl 版本没有改变。而且我无法编译。任何人建议任何修复?