Lua compilation link error-Collection of common programming errors

When I try to compile a little lua program, I get these errors :

/usr/lib//liblua52.so: undefined reference to `dlsym'
/usr/lib//liblua52.so: undefined reference to `dlerror'
/usr/lib//liblua52.so: undefined reference to `dlopen'
/usr/lib//liblua52.so: undefined reference to `dlclose'

Of course, I link with -ldl. I have lua5.2-dev installed on my ubuntu. If you need any more infos ask me.

Thanks!

  1. When I try to compile a little lua program, I get these errors

    No. You get these errors when you link the program.

    The fix is to add -ldl at the end of your link line.

  2. The easy way to get this error is to have your PLAT variable set wrong in the Makefile. You need to set it in the top level Makefile and the src/Makefile.

    The legal values show up about 10 lines down from the definition.

Originally posted 2013-11-27 12:00:27.