2015-07-15 6 views
3

Мне нужно скомпилировать C-программу на linux (ubuntu) с gcc. Это зависит от библиотек openssl.Скомпилировать открытую SSL-зависимую программу C с помощью GCC

#include <openssl/crypto.h> 
#include <openssl/pem.h> 
#include <openssl/err.h> 
#include <openssl/bio.h> 
#include <openssl/x509.h> 
#include <openssl/pem.h> 
#include <openssl/err.h> 

Я загрузил пакет libcrypto и libopenssl из репозитория. Но до сих пор я получаю эту ошибку

[email protected]:~/openssl# gcc opensslhello.c 
/tmp/ccTahV7g.o: In function `pem2X509': 
opensslhello.c:(.text+0x15): undefined reference to `BIO_s_mem' 
opensslhello.c:(.text+0x1d): undefined reference to `BIO_new' 
opensslhello.c:(.text+0x4e): undefined reference to `BIO_write' 
opensslhello.c:(.text+0x71): undefined reference to `PEM_read_bio_X509' 
opensslhello.c:(.text+0x7f): undefined reference to `BIO_free' 
/tmp/ccTahV7g.o: In function `sendHelloFunction': 
opensslhello.c:(.text+0xb9): undefined reference to `X509_STORE_new' 
opensslhello.c:(.text+0xe2): undefined reference to `X509_STORE_add_cert' 
opensslhello.c:(.text+0x106): undefined reference to `X509_STORE_add_cert' 
opensslhello.c:(.text+0x113): undefined reference to `sk_new_null' 
opensslhello.c:(.text+0x13c): undefined reference to `sk_push' 
opensslhello.c:(.text+0x160): undefined reference to `sk_push' 
opensslhello.c:(.text+0x187): undefined reference to `X509_STORE_CTX_new' 
opensslhello.c:(.text+0x1b0): undefined reference to `X509_STORE_CTX_init' 
opensslhello.c:(.text+0x1bf): undefined reference to `X509_verify_cert' 
opensslhello.c:(.text+0x1d3): undefined reference to `X509_STORE_CTX_get_error' 
opensslhello.c:(.text+0x1e3): undefined reference to `X509_STORE_CTX_get_error' 
opensslhello.c:(.text+0x215): undefined reference to `X509_STORE_CTX_free' 
opensslhello.c:(.text+0x220): undefined reference to `X509_free' 
opensslhello.c:(.text+0x22b): undefined reference to `BIO_free' 
opensslhello.c:(.text+0x233): undefined reference to `X509_free' 
opensslhello.c:(.text+0x23e): undefined reference to `sk_pop_free' 
opensslhello.c:(.text+0x249): undefined reference to `X509_STORE_free' 
/tmp/ccTahV7g.o: In function `main': 
opensslhello.c:(.text+0x291): undefined reference to `EVP_cleanup' 
opensslhello.c:(.text+0x29d): undefined reference to `ERR_remove_state' 
opensslhello.c:(.text+0x2a2): undefined reference to `ERR_free_strings' 
collect2: error: ld returned 1 exit status 
[email protected]:~/openssl# 

Может кто-нибудь пожалуйста, скажите мне, что я должен сделать, чтобы, чтобы избавиться от этой ошибки.?

Спасибо,

ответ

3

Вы не связаны крипто и OpenSSL библиотеки:

gcc opensslhello.c -lssl -lcrypto 
+0

Спасибо большое :) –

Смежные вопросы