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 <spartan.leader@gmail.com> wrote:
> I am a lua newcomer and mainly want to embed lua in c.
> I have followed this tutorial (
> http://gamedevgeek.com/tutorials/getting-started-with-lua/ ).
> 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.

Scott

> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/SOLVED%3AProblem-embedding-lua-in-c-tp21380277p21380277.html
> Sent from the Lua - General mailing list archive at Nabble.com.
>
>