This function searches and loads the shared library modulename almost like the standard lua function require. However this function ensures that the shared library is loaded in a way maximally compatible with C++ code and also ensures that it will remain loaded when the Lua state is closed.

This is necessary when the shared library defines classes whose instances outlive the Lua interpreter. This function supports none of the advanced search methods implemented by the usual function require, other than searching a shared library along package.cpath.