In my system (Slackware64-14.1) gawk is installed in version 4.1.0. I'd like to install gawkextlib to have access to some of its features, namely xml.

From the README file of gawkextlib-0.4.9:

To use this library, you must first build the new version of gawk containing shared extension library support. Please use gawk 4.1 or later, or use this recipe to build from the git sources:

git clone git://git.savannah.gnu.org/gawk.git cd gawk
./bootstrap.sh ./configure --prefix=/tmp/newgawk make && make check && make install

After you build and install that in /tmp/newgawk, you can then build gawkextlib like so:

Using git: git clone git://git.code.sf.net/p/gawkextlib/code gawkextlib cd gawkextlib ./update-autotools

Or it may be easier from a tarball if you do not have current autotools installed: tar xf gawkextlib-.tar.gz cd gawkextlib-

Either way, the steps to build are the same: ./configure --with-gawk=/tmp/newgawk --prefix=/tmp/newgawk make && make check && make install

The process fails with:

/usr/bin/mkdir -p '/tmp/newgawk/lib/gawk' /bin/sh ../libtool
--mode=install ../build-aux/install-sh -c xml.la gd.la mpfr.la '/tmp/newgawk/lib/gawk' libtool: install: error: cannot install `xml.la' to a directory not ending in /usr/lib/gawk make[2]: * [install-pkgextensionLTLIBRARIES] Error 1

This is not a big problem, as I'd really like gawkextlib to integrate with existing gawk residing in /usr. So, when:

$ ./configure --prefix=/usr --with-gawk=/usr
$ make && make test 
# make install

Everything installs fine.

# ls /usr/lib/libgawkextlib.*
/usr/lib/libgawkextlib.la  /usr/lib/libgawkextlib.so  /usr/lib/libgawkextlib.so.0  /usr/lib/libgawkextlib.so.0.0.0


$ awk -l xml
awk: fatal: can't open shared library `xml' for reading (No such file or directory)

From gawk man page:


--load lib Load a shared library lib. This searches for the library using the AWKLIBPATH environment variable. If the initial search fails, another attempt will be made after appending the default shared library suffix for the platform. The library initialization routine is expected to be named dl_load().

After setting up AWKLIBPATH:

$ export AWKLIBPATH=/usr/lib
$ echo $AWKLIBPATH          
$ awk -l xml
awk: fatal: can't open shared library `xml' for reading (No such file or directory)

awk aka gawk can't find the shared library. What am I missing here?

  • Do you get that error when you use gawk as well or only with awk?
    – terdon
    Nov 28, 2013 at 17:28
  • @terdon: $ ll *awk lrwxrwxrwx 1 root root 4 Nov 9 22:58 awk -> gawk lrwxrwxrwx 1 root root 10 Nov 9 22:58 gawk -> gawk-4.1.0 so awk == gawk in my system.
    – Luis
    Nov 28, 2013 at 17:33
  • Yeah, I'm just wondering if invoking it as awk causes it to run in compatibility mode, as though run with --posix. I have no idea if this is the case, but you may as well try it with gawk just on the off chance. Both bash and gksudo change their behavior depending on which name you use to invoke them, there may be something similar for gawk.
    – terdon
    Nov 28, 2013 at 17:47
  • I don't think it's a path problem, I followed the same basic procedure and get a more informative error: gawk: fatal: load_ext: cannot open library '/usr/local/lib/gawk/xml.so' (libgawkextlib.so.0: cannot open shared object file: No such file or directory) but /usr/local/lib/gawk/xml.so exists and is readable.
    – terdon
    Nov 28, 2013 at 19:05
  • I had the same problem installing pgsql (and gawkextlib) to a private path. Setting export LD_LIBRARY_PATH=/mypath/lib (where libgawkextlib.so.0 exists) solved the problem. I verified this with strace /mypath/bin/gawk '@load "pgsql"'. This was in Ubuntu. Jan 17, 2019 at 9:11

2 Answers 2


As there were no answers, I asked in the gawkextlib mailing list about this problem. One of the authors of the project, Andrew Schorr, suggested that one could use the following command:

./configure --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info

As there were some superfluous options, I stripped it down to:

./configure  --datadir=/usr/share  --libdir=/usr/lib64

And gawkextlib installs fine and is usable with gawk. One can also add the option --prefix=/usr to have xmlgawk script installed in /usr/bin instead of /usr/local/bin.


I just encountered this issue, and James Brown's comment really helped. I had to add the following environment variables:

export AWKLIBPATH=/usr/local/lib/gawk/   # path where xml.so exists
export LD_LIBRARY_PATH=/usr/local/lib/   # path where libgawkextlib.so.0 exists

But I think the answer from Luis is better in the long run. According to The Linux Documentation Project: "LD_LIBRARY_PATH is handy for development and testing, but shouldn't be modified by an installation process for normal use by normal users"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .