The pkgconfig file installed by dev-lang/lua-5.1.5-r5 has an incomplete Libs setting. It is missing Libs.private: -ldl, which causes undefined symbol errors when linking agains liblua.a. See bug 706492 for an example of this.
fixed in slotted lua.