Remember the first time LUA and C call each other example _php tutorial

Source: Internet
Author: User

Remember the first time LUA and C call each other example


(The following is a reference to other people's examples, hereby stated)
Before writing a program, you need to install the LUA environment
In the terminal input command:
 
  
  
  1. sudo apt-get install lua5.1
After installation, enter Lua-v to view the LUA version:

Recommendation: Enter Ln-s lua5.1 lua, make a soft link, and run Lua at a later time lua5.1
Part I: The C language calls Lua functions (Ubuntu)
1. Write a ADD.C file first

2. Write another Lua function (Add.lua) that we will call

3. Finally, use the command: Gcc-o add add.c-i/usr/include/lua5.1-llua5.1, generate the Add executable file,

Part II: LUA calls C-language functions (Ubuntu)
1. Write a Hello.lua file

2. Write a power_lua.c file again

3. Run command: Gcc-wall-shared-fpic-o power.so-i/usr/include/lua5.1 power_lua.c
You will see the power.so file in the current directory

4. Finally, the exciting moment is up!
Run: Lua Hello.lua, the results are as follows:

http://www.bkjia.com/PHPjc/1115819.html www.bkjia.com true http://www.bkjia.com/PHPjc/1115819.html techarticle Remember the first time Lua and C invoke each other example (the following reference to other people's examples, hereby stated) before writing the program, you need to install the LUA environment in the terminal Input command: sudo apt-get i ...

  • 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.