lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, Jan 9, 2009 at 10:57 PM, 2weird <> wrote:
> I am a lua newcomer and mainly want to embed lua in c.
> I have followed this tutorial (
> ).
> Compiling the given example as C++ works perfectly but compiling in C I get
> the following error:
> [...]
> /usr/local/lib/liblua.a(lmathlib.o): In function `math_tan':
> lmathlib.c:(.text+0x19e): undefined reference to `tan'
> /usr/local/lib/liblua.a(lmathlib.o): In function `math_tanh':
> lmathlib.c:(.text+0x1de): undefined reference to `tanh'
> /usr/local/lib/liblua.a(lmathlib.o): In function `math_sqrt':
> lmathlib.c:(.text+0x241): undefined reference to `sqrt'
> [...]
> collect2: ld returned 1 exit status
> I removed extern "C" and followed the instructions to the last detail.
> Can someone tell me what the problem is?
   It isn't linking C's standard math library, which is required by
lmathlib. Adding -lm ("link to libm") to the compiler arguments should
fix it.


> Thanks in advance.
> --
> View this message in context:
> Sent from the Lua - General mailing list archive at