Hi,

my problem is solved. 

Thanks anyway,
Minh.
-------------------
> Hi Dinh Thao,
> thank you very much for your reply. I have no more problem with
> linking.
> but now I have problem when I compile file client.c and common.c:
> 
> [EMAIL PROTECTED]:~/SSL-connection$ gcc client.c -o client -Wall
-lcrypto
> -lssl -lpthread
> /tmp/ccUugnSm.o: In function `main':
> client.c:(.text+0xcb): undefined reference to `init_OpenSSL'
> client.c:(.text+0xfc): undefined reference to `handle_error'
> client.c:(.text+0x13f): undefined reference to `handle_error'
> collect2: ld returned 1 exit status
> 
> Can you tell me where is problem?
> 
> Thanks, Minh. 
>  ====================
> Here ist relevant code:
> 
> common.h================
> #include <openssl/bio.h>
> #include <openssl/err.h>
> #include <openssl/rand.h>
> #include <openssl/ssl.h>
> #include <openssl/x509v3.h>
> 
> #ifndef WIN32
> #include <pthread.h>
> #define THREAD_CC
> #define THREAD_TYPE                    pthread_t
> #define THREAD_CREATE(tid, entry, arg) pthread_create(&(tid), NULL,
\
>                                                       (entry),
(arg))
> #else
> #include <windows.h>
> #define THREAD_CC                      __cdecl
> #define THREAD_TYPE                    DWORD
> #define THREAD_CREATE(tid, entry, arg) do { _beginthread((entry), 0,
> (arg));\
>                                             (tid) =
> GetCurrentThreadId();   \
>                                        } while (0)
> #endif
> 
> #define PORT            "6001"
> #define SERVER          "splat.zork.org"
> #define CLIENT          "shell.zork.org"
> 
> #define int_error(msg)  handle_error(__FILE__, __LINE__, msg)
> void handle_error(const char *file, int lineno, const char *msg);
> 
> void init_OpenSSL(void);
> 
> common.c==========
> #include "common.h"
> 
> void handle_error(const char *file, int lineno, const char *msg)
> {
>     fprintf(stderr, "** %s:%i %s\n", file, lineno, msg);
>     ERR_print_errors_fp(stderr);
>     exit(-1);
> }
> 
> void init_OpenSSL(void)
> {
>     if (!SSL_library_init())
>     {
>         fprintf(stderr, "** OpenSSL initialization failed!\n");
>         exit(-1);
>     }
>     SSL_load_error_strings();
> }
> 
> client.c============
> #include "common.h"
> 
> void do_client_loop(BIO *conn)
> {
>     int  err, nwritten;
>     char buf[80];
> 
>     for (;;)
>     {
>         if (!fgets(buf, sizeof(buf), stdin))
>             break;
>         for (nwritten = 0;  nwritten < sizeof(buf);  nwritten +=
err)
>         {
>             err = BIO_write(conn, buf + nwritten, strlen(buf) -
> nwritten);
>             if (err <= 0)
>                 return;
>         }
>     }
> }
> 
> int main(int argc, char *argv[])
> {
>     BIO  *conn;
> 
>     init_OpenSSL();
> 
>     conn = BIO_new_connect(SERVER ":" PORT);
>     if (!conn)
>         int_error("Error creating connection BIO");
> 
>     if (BIO_do_connect(conn) <= 0)
>         int_error("Error connecting to remote machine");
> 
>     fprintf(stderr, "Connection opened\n");
>     do_client_loop(conn);
>     fprintf(stderr, "Connection closed\n");
> 
>     BIO_free(conn);
>     return 0;
> }
> 
>
______________________________________________________________________
> OpenSSL Project                                
http://www.openssl.org
> User Support Mailing List                   
openssl-users@openssl.org
> Automated List Manager                          
[EMAIL PROTECTED]
> 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to