在C中嵌入lua代码 [英] embedding lua code in c
问题描述
我试图按照此处给出的基本指南进行操作,将lua嵌入到C中.我复制了将代码逐字放入我自己的embed.c文件中,并执行列出的确切编译器命令:
I am attempting to follow the besic guide given here on embedding lua into C. I copied the code verbatim into my own embed.c file and executed the exact compiler command listed:
cc -o embed embed.c \
-I/usr/local/include \
-L/usr/local/lib \
-llua -llualib
我得到了错误:
embed.c:19:14: error: invalid storage class for function ‘openlualibs’
之后,我将功能移到了main
之外,再次进行了编译,并得到了:
After which I moved the functions outside of main
, compiled again, and got:
/usr/bin/ld: cannot find -llualib
为什么我不能编译它,我感到茫然. lua已正确安装.还有其他人遇到过这些问题吗?如果这是一个糟糕的教程,请随时将我直接引导到一个连击者.
I am at a loss for why I cannot compile this. lua is installed properly. has anyone else encountered these problems? If this is a bad tutorial, please feel free to simply direct me to a batter one.
推荐答案
在某些Linux发行版中,您可能需要安装lua-devel
(或类似命名的)软件包,以便获得正确的头文件和库符号链接.根据软件包编译和链接项目.如果您有liblualib-<version>.so.<version>
,例如liblualib-5.so.5.0
,则可能需要安装devel软件包.
On some Linux distributions you may need to install the lua-devel
(or similar named) package, in order to get the proper header files and library symlinks required for compiling and linking projects against the package. If you do have a liblualib-<version>.so.<version>
, for example liblualib-5.so.5.0
, you may need to install the devel package.
从lua 5.1开始,liblualib
不存在.这是发行公告: http://lua-users.org /lists/lua-l/2005-05/msg00186.html
Starting with lua 5.1, liblualib
does not exist. Here is the release announcement: http://lua-users.org/lists/lua-l/2005-05/msg00186.html
这篇关于在C中嵌入lua代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!