li_jessen
li_jessen

Reputation: 478

How to fix: gawk: error while loading shared libraries: libreadline.so.4: cannot open shared object file: No such file or directory

I was running make and encountered the following error:

gawk: error while loading shared libraries: libreadline.so.4: cannot open shared object file: No such file or directory
config.status: error: could not create mjson.pc
Reaping losing child 0x564b30cbed70 PID 48255
make[1]: *** [Makefile:44: libmjson] Error 1
Removing child 0x564b30cbed70 PID 48255 from chain.
make[1]: Leaving directory '/home/minipc/econet/apps/public/libjson-1.5'

The libreadline.so.4 is too old to install in my current Linux machine (Ubuntu 20.04). So instead I installed libreadline.so.8, and created a symbolic link to libreadline.so.4. And I checked, it works:

lrwxrwxrwx 1 root root     25 Aug 12 21:17 /lib32/libreadline.so.4 -> /lib32/libreadline.so.8.0
lrwxrwxrwx 1 root root     18 Feb 25  2020 /lib32/libreadline.so.8 -> libreadline.so.8.0
-rw-r--r-- 1 root root 311884 Feb 25  2020 /lib32/libreadline.so.8.0

And the relevant part in Makefile is the following:

./configure  --prefix=/home/minipc/econet/apps/public/libjson-1.5 --libdir=/lib32 --includedir=/lib32 --disable-static --enable-shared \ 

And I checked it in the console output when running the make.

So why it still can't find libreadline.so.4? Is it because libreadline.so.8.0 too new to be linked by libreadline.so.4 so the program doesn't recognize it?

Also, when I run

$ ldconfig -p|grep libreadline
        libreadline.so.8 (libc6,x86-64) => /lib/x86_64-linux-gnu/libreadline.so.8
        libreadline.so.8 (libc6) => /lib32/libreadline.so.8
        libreadline.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libreadline.so.5

Only libreadline.so.5 and libreadline.so.4 appears. So the softlink would not be recognized by the system?

Upvotes: 2

Views: 1503

Answers (2)

knb
knb

Reputation: 9393

It could be that your gawk was called indirectly, because it was symlinked to from awk. And it was actually awk that was called in our configure or make script.

So another strategy might be to temporarily symlink awk from gawk to mawk:

sudo update-alternatives --set awk /usr/bin/mawk

Then try to run make again. This strategy is simple and worth a shot. If it does not help, switch back awk from mawk to gawk afterwards.


I had this problem while I was using Vagrant to start up a VirtualBox Guest VM.
Command vagrant up never succeeded.

I received a related error message (Stderr: line in this block:).

==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["showvminfo", "c036383a-9b24-4730-87c3-19a5074b46e6", "--machinereadable"]

Stderr: awk: symbol lookup error: /tmp/.mount_vagranUCoOLf/usr/lib/libreadline.so.8: undefined symbol: UP
######### (mixed up with more unrelated error messages) ##########

My primary goal was not to fix the gawk / libncurses/ readline shared-library problem, but to find a way to circumvent the gawk crash, simply start up a VM.

Perhaps this helps someone out there....

Upvotes: 2

li_jessen
li_jessen

Reputation: 478

The libreadline.so.8 maybe too new to be used as the source of symbolic link of libreadline.so.4. Or it may need to be in another directory such as /lib to be linked by gawk.

I try $gawk return command not found . Then I run $sudo apt install gawk and check the gawk is of version GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0). I run $make again and found the same error.

Then I try $export $AWKPATH and find out that there is another path to store the gawk bin. Then I enter the directory and run $gawk, the same error pop out. I copy the /usr/bin/gawk ( the newly installed gawk) to update the gawk in the directory, and then run $gawk, it is the newest one.

Then I run $make again and the issue got solved.

Upvotes: 2

Related Questions