lua-users home
lua-l archive

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


François-Xavier INGLESE wrote:
> But the result is always the same : when I run "main.lua" in my C/C++
> program, it doesn't load. 
> As soon as I remove the "require" or "dofile" line, the file loads
> well. 
> 
> [...]
> 
> Is it possible to achieve what I'am trying to do ?
> Or perhaps should I make a C/C++ function which will be called to load
> the "a.lua" and "b.lua" ?
> Or is it supposed to work like that and I only have a directory path
> problem ?

It depends on how you load and run your main.lua file from C. In any case though when the execution fail, the Lua API function that you used to execute the script must be returning you an error, which explicit what happened. If you used lua_pcall, luaL_dostring or luaL_dofile, and the return value is non-zero, there should be a string on the Lua stack describing the error. You can display it with:

    printf("%s\n", lua_tostring(L, -1));

or whatever function you use for logging in your application.