Thanks for the reply, Drake.
When I tried adding -shared to the compile line, I got a strange error:
matt@matt-BM412AA-ABA-CQ5600Y:~/Downloads/lua-5.2.0/src$ g++ dir.cpp -o
test.so -llua -shared
/usr/bin/ld: /usr/local/lib/liblua.a(lapi.o): relocation R_X86_64_32
against `luaO_nilobject_' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/liblua.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
It says to recompile with fPIC (whatever that is?), but I tried that and
still got the same exact error.