clualanguage-binding

calling c code from lua


I tried to follow this: http://www.troubleshooters.com/codecorn/lua/lua_lua_calls_c.htm

I tried to compile the c code like it says in the guide:

gcc -Wall -shared -fPIC -o power.so -I/usr/include/lua5.1 -llua5.1 hellofunc.c

but I got http://pastebin.com/KQvA0qFH which I recognized as the error you get when you forget to include a lib or framework but I did -I/usr/include/lua5.1

If it matters I am running os x and I installed lua with brew


Solution

  • You haven't told it where to find lua5.1

    use -L to tell the compiler where the library is located

    From your own example page it says to look at http://www.troubleshooters.com/codecorn/lua/lua_c_calls_lua.htm#_Anatomy_of_a_Lua_Call