lua-users home
lua-l archive

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


Am 22.12.2010 16:43, schrieb Terry Bayne:
The context is Lua embedded in a host program. Various modules and additional Lua files are stored in a subdirectory (/HostAppDir/modules and /HostAppDir/LuaFiles) located at the root directory of the the host program.

Given the directory names shown, what would be the proper way to set the PATH and CPATH so that the require statement works correctly for locating DLLs and additional Lua files?

And I assume I should set those values in the Lua Environment BEFORE loading my main Lua file.

Am I even close?
There are different issues in this topic.

* package.path is used, when require searches for a lua-module.
* package.cpath is used, when require searches for a dll/shared lib.

BUT

* when the dll/shared lib depends on other dlls/shared libs, the search path for these are completely outside the control of lua. For windows the environmentvariable PATH is used, for linux LD_LIBRARY_PATH may be used (see man ld.so)

So you might have to set these environment variables for the process either before calling it or inside the main program before using require or similar.

Regards, Jørgen