lua-users home
lua-l archive

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


2010/6/20 RAN GREENBERG <ran_greenberg@hotmail.com>:
> i have tried it with extern c but still i get the same failed output
>
>> Date: Sun, 20 Jun 2010 13:36:45 +0100
>> Subject: Re: embedding lua with c
>> From: lua@corsix.org
>> To: lua@bazar2.conectiva.com.br
>>
>> 2010/6/20 RAN GREENBERG <ran_greenberg@hotmail.com>:
>> > #include <lua.h>
>> > #include <lualib.h>
>> > #include <lauxlib.h>
>> > ...
>> > when compiling with the command
>> > gcc -llua test.cpp
>> >
>>
>> If Lua is compiled as C code (which it most likely is) then when
>> compiling C++ code, you have to include it as C code by doing:
>> extern "C" {
>> #include <lua.h>
>> #include <lualib.h>
>> #include <lauxlib.h>
>> }

As a command line, you likely want to use the following instead of
what you're currently doing:
g++ test.cpp -llua -ldl -lm