Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:04:07+00:00 2026-06-17T21:04:07+00:00

I’m reading this book Network Security with OpenSSL by Pravir Chandra, Matt Messier and

  • 0

I’m reading this book Network Security with OpenSSL by Pravir Chandra, Matt Messier and John Viega and I’m trying to create an SSL client/server connection after their example in the book using OpenSSL but I get this error and I don’t know why.

This is my server:

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

#include <pthread.h>

#define PORT            "6001"
#define SERVER          "splat.zork.org"
#define CLIENT          "shell.zork.org"

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 (!THREAD_setup() || !SSL_library_init())
    {
        fprintf(stderr, "** OpenSSL initialization failed!\n");
        exit(-1);
    }
    SSL_load_error_strings();
}


void do_server_loop(BIO *conn)
{
    int  done, err, nread;
    char buf[80];

    do
    {
        for (nread = 0;  nread < sizeof(buf);  nread += err)
        {
             err = BIO_read(conn, buf + nread, sizeof(buf) - nread);
             if (err <= 0)
                 break;
        }
        fwrite(buf, 1, nread, stdout);
    }
    while (err > 0);
}

void *server_thread(void *arg)
{
    BIO *client = (BIO *)arg;

    pthread_detach(pthread_self(  ));

    fprintf(stderr, "Connection opened.\n");
    do_server_loop(client);
    fprintf(stderr, "Connection closed.\n");

    BIO_free(client);
    ERR_remove_state(0);
}

int main(int argc, char *argv[])
{
    BIO *acc, *client;

    pthread_t tid;

    init_OpenSSL();

    acc = BIO_new_accept(PORT);
    if (!acc)
        handle_error(__FILE__, __LINE__, "Error creating server socket");

    if (BIO_do_accept(acc) <= 0)
        handle_error(__FILE__, __LINE__, "Error binding server socket");

    for (;;)
    {
        if (BIO_do_accept(acc) <= 0)
            handle_error(__FILE__, __LINE__, "Error accepting connection");

        client = BIO_pop(acc);
        pthread_create(&tid, NULL, server_thread, client);
    }

    BIO_free(acc);
    return 0;
}

I’m compiling the source using gcc:

$ gcc -o server server.c -lssl -crypto -lpthread -lm
Undefined symbols for architecture i386:
  "_ERR_print_errors_fp", referenced from:
      _handle_error in ccgAll3d.o
  "_THREAD_setup", referenced from:
      _init_OpenSSL in ccgAll3d.o
  "_BIO_read", referenced from:
      _do_server_loop in ccgAll3d.o
  "_BIO_free", referenced from:
      _server_thread in ccgAll3d.o
  "_ERR_remove_state", referenced from:
      _server_thread in ccgAll3d.o
  "_BIO_new_accept", referenced from:
      _main in ccgAll3d.o
  "_BIO_ctrl", referenced from:
      _main in ccgAll3d.o
  "_BIO_pop", referenced from:
      _main in ccgAll3d.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

Can anyone tell me why is this happening?

I got something similar some time ago and solved it by defining the functions that were problematic but this doesn’t work anymore.

I’m compiling the source on a Mac OS X 10.6.8.
Is it because I’m using a 32-bit system?

This is the command I’m compiling with gcc -Wall -lssl -crypto -lpthread -lm -o server server.c

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:04:08+00:00Added an answer on June 17, 2026 at 9:04 pm

    You’ll be a little closer with gcc -o server sslserver.c -pthread -lssl.

    Also the book’s errata inform us that SSL_init_library should be SSL_library_init.

    The only undefined reference left is ‘THREAD_setup’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.