lua-users home
lua-l archive

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

2010/1/13 James Hearon <>:
> linux f10.  I have Lua installed and it runs from the command line.
> $ lua
> Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
> I built a library, random, editing the makefile to reflect the location of
> my Lua installation per instructions in the readme of the library sources.
> In general I cannot get Lua "require" to work, unless the .lua is
> specifically located in the same folder as the library, and the compiled
> .cpp is executed also from within the same directory as the library.

If require fails, it should throw an error, which message lists the
various paths that were tried to locate the module ('random'). Can you
send us the complete error message with the path list and the stack
trace ?

Note that your C code only checks for compilation errors, not runtime
errors. You should check the return value of luaL_dofile. Also since
luaL_dofile is loading the file itself (and will report compilation
errors too), the call to luaL_loadfile is just useless in that case.