Como compilar um programa simples com OpenSSL?

Estou tentando compilar um programa ssl simples (foi retirado do código-fonte do livro openssl). O programa possui os seguintes arquivos: common.h common.c client.c server.c

Instalei o openssl 0.9.7, portanto, tenho a mesma versão do livro. Fiz o download da fonte e ./ Configure, faça, faça teste, faça instalação no diretório inicial.

No common.h existem os seguintes itens:

#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/ssl.h>
#include <openssl/x509v3.h> 

Eu corrogcc -Wall common.c client.c -o client mas eu recebo os seguintes erros:

common.c: In function ‘init_OpenSSL’:
common.c:12:5: warning: implicit declaration of function ‘THREAD_setup’
/tmp/ccvI3HX4.o: In function `handle_error':
common.c:(.text+0x3a): undefined reference to `ERR_print_errors_fp'
/tmp/ccvI3HX4.o: In function `init_OpenSSL':
common.c:(.text+0x51): undefined reference to `THREAD_setup'
common.c:(.text+0x5a): undefined reference to `SSL_library_init'
common.c:(.text+0x97): undefined reference to `SSL_load_error_strings'
/tmp/ccRA0Co9.o: In function `do_client_loop':
client.c:(.text+0x71): undefined reference to `BIO_write'
/tmp/ccRA0Co9.o: In function `main':
client.c:(.text+0xbb): undefined reference to `BIO_new_connect'
client.c:(.text+0x106): undefined reference to `BIO_ctrl'
client.c:(.text+0x18e): undefined reference to `BIO_free'
collect2: ld returned 1 exit status

Obviamente, ele não pode vincular aos arquivos de cabeçalho ... Quando eu corro como sugerido em um fórumgcc -Wall common.c client.c -o cliente -lcrypto -lssl Eu receb

common.c: In function ‘init_OpenSSL’:
common.c:12:5: warning: implicit declaration of function ‘THREAD_setup’
/tmp/cc2gjx8W.o: In function `init_OpenSSL':
common.c:(.text+0x51): undefined reference to `THREAD_setup'
collect2: ld returned 1 exit status

Mas adicionar -lpthread não ajudará a resolver o problema ...

Alguma idéia de por que isso acontece e como resolvê-l

Meu palpite é que o lcrypto e o lssl são instalados por padrão no ubuntu e, ao fazê-lo, o -lcypto diz ao vinculador para examinar os cabeçalhos do sistema e não os da instalação openssl ...

Qualquer ajuda ou indicação é apreciada!

Obrigado

questionAnswers(1)

yourAnswerToTheQuestion