Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call so file in lua script

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to call so file in lua script. The content is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something from the detailed introduction of this article.

#include #include #include

#include

#include

// lua script 5.1.5 int getA(lua_State* luaEnv)

{

char a[44] = "test"; //push lua_pushstring(luaEnv,a);

return 1;

}

//Method list.

static luaL_Reg luaLibs[] =

{

{"getA", getA},

{NULL, NULL}

};

//int luaopen_show(lua_State* luaEnv)

{

const char* const LIBRARY_NAME = "show"; //Register

luaL_register(luaEnv, LIBRARY_NAME, luaLibs);

return 1;

}

Pack c Command gcc -c -fPIC -o show.o show.c gcc -shared -o show.so show.o

lua script calls show.so local show= require "show" a=show.getA() prints a as test

The above is how to call so file in lua script. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report