On Jun 2, 2012, at 11:18 AM, Dan Eloff wrote: > I declared in lua.cpp: > > extern "C" int foo(int bar) > { > return bar *en in lua bar; Not sure what that means? > } > > Then in lua: > > local ffi = require("ffi") > ffi.cdef[[ > int foo(int bar); > ]] > local barreturn = lib.foo(5) Replace above line with: local barreturn = ffi.C.foo(5) > io.write(barreturn) > io.write('\n') > > And I load and execute this via luaL_dofile in main.cpp > > Which produces the error: "undefined symbol: foo" > > I added -rdynamic to gcc flags and running "nm -g mybinary | grep foo" I get: > > 00000000004089fc T foo > > I'm running on linux with latest "stable" luajit 2 and gcc++ 4.7 > > Cheers, > Dan >