$ curl -R -O http://www.lua.org/ftp/lua-5.2.3.tar.gz
$ tar zxf lua-5.2.3.tar.gz
$ cd lua-5.2.3
$ sudo make install
It has installed liblua.a to /usr/local/lib/liblua.a
I try to link my library now and get:
1 2 3 4 5 6 7 8 9 10 11
$ make
g++ -o bin/luaTest int/luaWrap.o int/luaTest.o -L/usr/local/lib -llua
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0x7d2): undefined reference to `dlsym'
loadlib.c:(.text+0x819): undefined reference to `dlerror'
loadlib.c:(.text+0x846): undefined reference to `dlopen'
loadlib.c:(.text+0x8bc): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0xa50): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [bin/luaTest] Error 1
How would I debug this? The library built fine, but now when I link to it and build I get errors inside of the 3rd party lib. When looking in the 3rd party source I notice this comment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#if defined(LUA_USE_DLOPEN)
/*
** {========================================================================
** This is an implementation of loadlib based on the dlfcn interface.
** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least
** as an emulation layer on top of native functions.
** =========================================================================
*/
#include <dlfcn.h>
staticvoid ll_unloadlib (void *lib) {
dlclose(lib); // one of the purpetrators
}
// Other purpetrators below.
Nevermind, found the answer... I needed to link to add -ldl to my linker line. Not sure how I would have figured that out without google!