Althttpd

Building althttpd ssl errors
Login

Building althttpd ssl errors

Building althttpd ssl errors

(1) By jose i cabrera (jicman) on 2022-05-22 02:57:25 [link] [source]

Greetings.

I am trying to build althttpd (althttpd-b8db19fe7e.zip) with this command,

jic@web:~/b/althttpd-b8db19fe7e$ sudo gcc -Os -o /usr/bin/althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c
althttpd.c:422:10: fatal error: openssl/bio.h: No such file or directory
  422 | #include <openssl/bio.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

As you can see I am probably missing some libraries. I am running,

Linux web 5.4.0-110-generic #124-Ubuntu SMP Thu Apr 14 19:46:19 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Any help would be greatly appreciated. Thanks.

josé

(2) By Stephan Beal (stephan) on 2022-05-22 13:30:08 in reply to 1 [link] [source]

As you can see I am probably missing some libraries

On Ubuntu-derived systems:

$ sudo apt install libssl-dev

(3) By jose i cabrera (jicman) on 2022-05-22 22:26:50 in reply to 2 [link] [source]

Thanks, libsse-dev installed:

jic@web:~/b/althttpd-b8db19fe7e$ sudo apt install libssl-dev
[sudo] password for jic:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  libssl-doc
The following NEW packages will be installed:
  libssl-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,584 kB of archives.
After this operation, 8,009 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl-dev amd64 1.1.1f-1ubuntu2.13 [1,584 kB]
Fetched 1,584 kB in 1s (2,225 kB/s)
Selecting previously unselected package libssl-dev:amd64.
(Reading database ... 116348 files and directories currently installed.)
Preparing to unpack .../libssl-dev_1.1.1f-1ubuntu2.13_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.1f-1ubuntu2.13) ...
Setting up libssl-dev:amd64 (1.1.1f-1ubuntu2.13) ...

Now, I get a different error,

jic@web:~/b/althttpd-b8db19fe7e$ sudo gcc -Os -o /usr/bin/althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c
/usr/bin/ld: /tmp/ccCQFMfJ.o: in function `tls_atexit':
althttpd.c:(.text+0x89): undefined reference to `SSL_free'
/usr/bin/ld: /tmp/ccCQFMfJ.o: in function `tls_write_server':
althttpd.c:(.text+0xbf2): undefined reference to `SSL_write'
/usr/bin/ld: althttpd.c:(.text+0xc00): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccCQFMfJ.o: in function `althttpd_fgets.constprop.0':
althttpd.c:(.text+0x16e4): undefined reference to `BIO_ctrl'
/usr/bin/ld: althttpd.c:(.text+0x16ff): undefined reference to `SSL_read'
/usr/bin/ld: althttpd.c:(.text+0x170d): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccCQFMfJ.o: in function `ProcessOneRequest':
althttpd.c:(.text+0x20e5): undefined reference to `BIO_new_socket'
/usr/bin/ld: althttpd.c:(.text+0x211d): undefined reference to `SSL_new'
/usr/bin/ld: althttpd.c:(.text+0x2136): undefined reference to `SSL_set_bio'
/usr/bin/ld: althttpd.c:(.text+0x213e): undefined reference to `SSL_accept'
/usr/bin/ld: althttpd.c:(.text+0x29dd): undefined reference to `BIO_ctrl'
/usr/bin/ld: althttpd.c:(.text+0x29f2): undefined reference to `SSL_read'
/usr/bin/ld: althttpd.c:(.text+0x2a03): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccCQFMfJ.o: in function `main':
althttpd.c:(.text.startup+0x603): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: althttpd.c:(.text.startup+0x60f): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: althttpd.c:(.text.startup+0x61b): undefined reference to `OPENSSL_init_crypto'
/usr/bin/ld: althttpd.c:(.text.startup+0x620): undefined reference to `TLS_server_method'
/usr/bin/ld: althttpd.c:(.text.startup+0x628): undefined reference to `SSL_CTX_new'
/usr/bin/ld: althttpd.c:(.text.startup+0x648): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x67f): undefined reference to `SSL_CTX_use_certificate_chain_file'
/usr/bin/ld: althttpd.c:(.text.startup+0x692): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x6c1): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/bin/ld: althttpd.c:(.text.startup+0x6d8): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x70c): undefined reference to `BIO_new_mem_buf'
/usr/bin/ld: althttpd.c:(.text.startup+0x71f): undefined reference to `X509_new'
/usr/bin/ld: althttpd.c:(.text.startup+0x73c): undefined reference to `PEM_read_bio_X509'
/usr/bin/ld: althttpd.c:(.text.startup+0x750): undefined reference to `SSL_CTX_use_certificate'
/usr/bin/ld: althttpd.c:(.text.startup+0x765): undefined reference to `X509_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x76f): undefined reference to `BIO_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x7a3): undefined reference to `BIO_new_mem_buf'
/usr/bin/ld: althttpd.c:(.text.startup+0x7be): undefined reference to `PEM_read_bio_PrivateKey'
/usr/bin/ld: althttpd.c:(.text.startup+0x7e1): undefined reference to `SSL_CTX_use_PrivateKey'
/usr/bin/ld: althttpd.c:(.text.startup+0x7f3): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x800): undefined reference to `BIO_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x826): undefined reference to `SSL_CTX_check_private_key'
/usr/bin/ld: althttpd.c:(.text.startup+0x859): undefined reference to `SSL_CTX_ctrl'
collect2: error: ld returned 1 exit status
jic@web:~/b/althttpd-b8db19fe7e$

Any thoughts?

jose

(4.1) By Stephan Beal (stephan) on 2022-05-23 00:16:04 edited from 4.0 in reply to 3 [link] [source]

althttpd.c:(.text+0x89): undefined reference to `SSL_free'

i'm wondering whether that's possibly openssl 3.x, which deprecated/removed some things. Can you post the output of:

apt show openssl | grep Version

My Mint 20.3 system has openssl 1.1, but Ubuntu 22.04 "upgraded" to 3.x (and broke my mail server by doing so).

If you have openssl 3.0 and that's the problem then i don't have a quick fix for you. We'll have to (in this project and its sibling, the Fossil SCM) figure out how to rewrite the SSL bits for the changes.

Edit: the ssl version (1.1) was in the output of your installation and i missed.

or...

sudo gcc -Os -o /usr/bin/althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c

Don't use sudo for compiling. That might be causing it to use a different library path than your user account would. Instead try:

gcc -Os -o althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c

And if that works then move the binary:

sudo mv althttpd /usr/bin/.
sudo chown root:root /usr/bin/althttpd

(5) By jose i cabrera (jicman) on 2022-05-22 23:45:43 in reply to 4.0 [link] [source]

i'm wondering whether that's possibly openssl 3.x, which deprecated/removed some things. Can you post the output of:

apt show openssl grep Version
jic@web:~/b/althttpd-b8db19fe7e$ apt show openssl | grep Version

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Version: 1.1.1f-1ubuntu2.13

I am going to reboot to see if that WARNING goes way. I will also try to compile it without the sudo. That could also be the problem: the compiler is looking at the wrong library.

I will return..,

(6) By jose i cabrera (jicman) on 2022-05-23 01:08:09 in reply to 4.1 [link] [source]

Don't use sudo for compiling. That might be causing it to use a different library path than your user account would. Instead try:

gcc -Os -o althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c

I get:

jic@web:~/b/althttpd-b8db19fe7e$ gcc -Os -o althttpd -fPIC -DENABLE_TLS -lssl -lcrypto althttpd.c
/usr/bin/ld: /tmp/ccr9I60V.o: in function `tls_atexit':
althttpd.c:(.text+0x89): undefined reference to `SSL_free'
/usr/bin/ld: /tmp/ccr9I60V.o: in function `tls_write_server':
althttpd.c:(.text+0xbf2): undefined reference to `SSL_write'
/usr/bin/ld: althttpd.c:(.text+0xc00): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccr9I60V.o: in function `althttpd_fgets.constprop.0':
althttpd.c:(.text+0x16e4): undefined reference to `BIO_ctrl'
/usr/bin/ld: althttpd.c:(.text+0x16ff): undefined reference to `SSL_read'
/usr/bin/ld: althttpd.c:(.text+0x170d): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccr9I60V.o: in function `ProcessOneRequest':
althttpd.c:(.text+0x20e5): undefined reference to `BIO_new_socket'
/usr/bin/ld: althttpd.c:(.text+0x211d): undefined reference to `SSL_new'
/usr/bin/ld: althttpd.c:(.text+0x2136): undefined reference to `SSL_set_bio'
/usr/bin/ld: althttpd.c:(.text+0x213e): undefined reference to `SSL_accept'
/usr/bin/ld: althttpd.c:(.text+0x29dd): undefined reference to `BIO_ctrl'
/usr/bin/ld: althttpd.c:(.text+0x29f2): undefined reference to `SSL_read'
/usr/bin/ld: althttpd.c:(.text+0x2a03): undefined reference to `SSL_get_error'
/usr/bin/ld: /tmp/ccr9I60V.o: in function `main':
althttpd.c:(.text.startup+0x603): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: althttpd.c:(.text.startup+0x60f): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: althttpd.c:(.text.startup+0x61b): undefined reference to `OPENSSL_init_crypto'
/usr/bin/ld: althttpd.c:(.text.startup+0x620): undefined reference to `TLS_server_method'
/usr/bin/ld: althttpd.c:(.text.startup+0x628): undefined reference to `SSL_CTX_new'
/usr/bin/ld: althttpd.c:(.text.startup+0x648): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x67f): undefined reference to `SSL_CTX_use_certificate_chain_file'
/usr/bin/ld: althttpd.c:(.text.startup+0x692): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x6c1): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/bin/ld: althttpd.c:(.text.startup+0x6d8): undefined reference to `ERR_print_errors_fp'
/usr/bin/ld: althttpd.c:(.text.startup+0x70c): undefined reference to `BIO_new_mem_buf'
/usr/bin/ld: althttpd.c:(.text.startup+0x71f): undefined reference to `X509_new'
/usr/bin/ld: althttpd.c:(.text.startup+0x73c): undefined reference to `PEM_read_bio_X509'
/usr/bin/ld: althttpd.c:(.text.startup+0x750): undefined reference to `SSL_CTX_use_certificate'
/usr/bin/ld: althttpd.c:(.text.startup+0x765): undefined reference to `X509_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x76f): undefined reference to `BIO_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x7a3): undefined reference to `BIO_new_mem_buf'
/usr/bin/ld: althttpd.c:(.text.startup+0x7be): undefined reference to `PEM_read_bio_PrivateKey'
/usr/bin/ld: althttpd.c:(.text.startup+0x7e1): undefined reference to `SSL_CTX_use_PrivateKey'
/usr/bin/ld: althttpd.c:(.text.startup+0x7f3): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x800): undefined reference to `BIO_free'
/usr/bin/ld: althttpd.c:(.text.startup+0x826): undefined reference to `SSL_CTX_check_private_key'
/usr/bin/ld: althttpd.c:(.text.startup+0x859): undefined reference to `SSL_CTX_ctrl'
collect2: error: ld returned 1 exit status

Any thoughts? Thanks.

jose

(7) By Stephan Beal (stephan) on 2022-05-23 01:14:07 in reply to 6 [link] [source]

Any thoughts?

Yes: don't run gcc manually ;). Run "make" instead. When i run gcc using the commands you did, i get the same error. Running make does the right thing, though.

The difference is in the order of the -l flags: those must come after the .c file:

$ gcc -Os -o althttpd -fPIC -DENABLE_TLS althttpd.c -lssl -lcrypto

will work for you.

(8) By jose i cabrera (jicman) on 2022-05-23 01:24:20 in reply to 7 [source]

Thanks. Both make and the command you provided above worked. I now have built althttpd. The documentation should be fixed because it has this command to build with ssl:

To build althttpd with built-in TLS support using libssl:

gcc -Os -o /usr/bin/althttpd -fPIC -DENABLE_TLS -lssl -lcrypto \
althttpd.c

This is what gives the error. Thanks for the help.

josé