So I don't understand shared objects very well. I'm trying to install a library called luapgsql, hosted
here, that allows lua scripts to interface with a PostgreSQL database. It's a little old, but the only alternative is luasql, which doesn't support parametrized queries and is therefore categorically unacceptable. luapgsql supports everything I need, anyway. I'm building this on NetBSD 5.0/amd64.
luapgsql is distributed as a single luapgsql.c file with a single header file luapgsql.h. It links to libpq via #include libpq-fe.h; the libpq libraries are all stored in /usr/pkg/lib, and libpq-fe.h is stored in /usr/pkg/include, as are lua.h and lauxlib.h (also linked to, but I'm not experiencing issues with them... yet). I'm building it like this:
Code:
gcc -o pgsql.so -O2 -fPIC -I/usr/pkg/include -shared luapgsql.c -L/usr/pkg/lib -lpq
It builds successfully and creates pgsql.so. Now the way lua modules work is you simply copy them into ${prefix}/include/lua/5.1/, and then you can use them via require(<library name>), which is in this case require(pgsql). I copied pgsql.so into /usr/pkg/lib/lua/5.1, and ran the little included test.lua which starts with require(pgsql)
At this point, lua complains "Error in module pgsql: cannot find shared object file libpq.so.5". Now, libpq.so.5 exists in /usr/pkg/lib, which looks like this:
Code:
$ ls /usr/pkg/lib
[...]
libpq.so
libpq.so.5
libpq.so.5.0.1
[...]
which to me should mean that libpq.so.5 is in the expected location; unfortunately, lua disagrees. Does anyone have any idea what I might be doing wrong, and how to fix it? 'twould be very much appreciated.
J