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 installAfter 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
but
$ awk -l xml
awk: fatal: can't open shared library `xml' for reading (No such file or directory)
From gawk
man page:
-l
--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
/usr/lib
$ 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?
gawk
as well or only withawk
?$ 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
soawk
==gawk
in my system.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 withgawk
just on the off chance. Bothbash
andgksudo
change their behavior depending on which name you use to invoke them, there may be something similar forgawk
.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.pgsql
(andgawkextlib
) to a private path. Settingexport LD_LIBRARY_PATH=/mypath/lib
(wherelibgawkextlib.so.0
exists) solved the problem. I verified this withstrace /mypath/bin/gawk '@load "pgsql"'
. This was in Ubuntu.