Use of Lua Package.path

Source: Internet
Author: User

You need to write a tool in Lua, C + + calls Lua, and this LUA will require other LUA scripts, set Package.path in the main LUA, but fail all the time, even if Lua doesn't compile.

Project_path == Project_path. " /?. LUA; "  = Package.path. " ; ".. Path    

Require "test"

Online Search A lot also did not find, accidentally thought is because there is no open corresponding Lua library so the LUA call is unsuccessful (novice one)?

And then add in C + +

    lua_pushcfunction (L, luaopen_package);    Lua_pushstring (L, lua_iolibname);     1 0 );     -1);

And then run it again, done!.

In fact, the above one open the corresponding library is not very flexible, it is best to load all the library at once, so as to avoid encountering such problems still have to check whether C part forgot to load LUA library,

// Open All Libraries    at once Lual_openlibs (L);

Use of Lua Package.path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.