compiler problem

This is a discussion on compiler problem within the C Programming forums, part of the General Programming Boards category; (I am a hobby programmer, so please for give me) I have a problem with GCC compiler when using openssl ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    3

    compiler problem

    (I am a hobby programmer, so please for give me)

    I have a problem with GCC compiler when using openssl libraries on Linux server.

    When compiling a sample code,

    gcc -o example example.c

    I get the following error:
    __________________________________________________

    /tmp/ccNvoBF9.o: In function `main':
    /tmp/ccNvoBF9.o(.text+0x177): undefined reference to `SSL_load_error_strings'
    /tmp/ccNvoBF9.o(.text+0x17c): undefined reference to `SSL_library_init'
    /tmp/ccNvoBF9.o(.text+0x184): undefined reference to `SSLv2_client_method'
    /tmp/ccNvoBF9.o(.text+0x18c): undefined reference to `SSL_CTX_new'
    /tmp/ccNvoBF9.o(.text+0x1a0): undefined reference to `SSL_new'
    /tmp/ccNvoBF9.o(.text+0x1b8): undefined reference to `SSL_set_fd'
    /tmp/ccNvoBF9.o(.text+0x1c7): undefined reference to `SSL_connect'
    /tmp/ccNvoBF9.o(.text+0x1e1): undefined reference to `SSL_get_current_cipher'
    /tmp/ccNvoBF9.o(.text+0x1ec): undefined reference to `SSL_CIPHER_get_name'
    /tmp/ccNvoBF9.o(.text+0x20b): undefined reference to `SSL_get_peer_certificate'
    /tmp/ccNvoBF9.o(.text+0x236): undefined reference to `X509_get_subject_name'
    /tmp/ccNvoBF9.o(.text+0x241): undefined reference to `X509_NAME_oneline'
    /tmp/ccNvoBF9.o(.text+0x270): undefined reference to `X509_get_issuer_name'
    /tmp/ccNvoBF9.o(.text+0x27b): undefined reference to `X509_NAME_oneline'
    /tmp/ccNvoBF9.o(.text+0x2a3): undefined reference to `X509_free'
    /tmp/ccNvoBF9.o(.text+0x2f0): undefined reference to `SSL_write'
    /tmp/ccNvoBF9.o(.text+0x318): undefined reference to `SSL_read'
    /tmp/ccNvoBF9.o(.text+0x36c): undefined reference to `SSL_shutdown'
    /tmp/ccNvoBF9.o(.text+0x38a): undefined reference to `SSL_free'
    /tmp/ccNvoBF9.o(.text+0x399): undefined reference to `SSL_CTX_free'

    _________________________________________________

    I have checked that functions are found from libraries on the server. Libraries should be behind the correct path /usr/include/openssl

    Can you advice me what could be a problem?

    Thank you!

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    your forgot to compile the ssl code into the program.

    so you should do "gcc example.c <ssl-thing-i-dont-know" -o example.


    headers just have prototypes, no code.


    its way to early right now.....................
    Last edited by mart_man00; 07-10-2003 at 05:09 AM.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    3
    mart_man00:

    I have ssl code located in the C-file.
    Example code is downloaded from Internet(may too long to post on the board). The example file includes main-function and ssl-funtions are called in the main-function.
    Also SSL-libraries are introduced in the code as well.

    example.c includes:

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

    and there are ssl-functions like

    SSL_write(ssl, request, strlen(request));
    SSL_write(ssl, request, strlen(request));

    ...

    All these ssl-functions should be correct. I tied to check them from ssl-libraries.

    I can post the code if needed.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    3

    Smile

    gcc -o example example.c -lssl -lcrypto

    works now perfectly.

    Many thanks for all!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++ compiler problem
    By GrasshopperEsq in forum C++ Programming
    Replies: 19
    Last Post: 05-08-2008, 03:35 AM
  2. Compiler Problem
    By sitestem in forum C++ Programming
    Replies: 2
    Last Post: 04-11-2004, 04:48 PM
  3. Replies: 5
    Last Post: 12-03-2003, 05:47 PM
  4. Problem with compiler
    By knight543 in forum C++ Programming
    Replies: 4
    Last Post: 02-09-2002, 09:16 PM
  5. Please help me with this compiler problem
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 01-05-2002, 05:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21