Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Lua 5.3未定义的参考_C++_Lua - Fatal编程技术网

C++ Lua 5.3未定义的参考

C++ Lua 5.3未定义的参考,c++,lua,C++,Lua,我正在尝试学习如何在C程序中嵌入lua,但我不擅长阅读技术文档,而且我还没有找到任何当前的教程。这是我的节目: #include <iostream> #include <lua.h> #include <lualib.h> #include <lauxlib.h> void report_errors(lua_State*, int); int main(int argc, char** argv) { for (int n = 1

我正在尝试学习如何在C程序中嵌入lua,但我不擅长阅读技术文档,而且我还没有找到任何当前的教程。这是我的节目:

#include <iostream>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>


void report_errors(lua_State*, int);

int main(int argc, char** argv) {
    for (int n = 1; n < argc; ++n) {
        const char* file = argv[n];
        lua_State *L = luaL_newstate();

        luaL_openlibs(L);

        std::cerr << "-- Loading File: " << file << std::endl;

        int s = luaL_loadfile(L, file);

        if (s == 0) {
            s = lua_pcall(L, 0, LUA_MULTRET, 0);
        }

        report_errors(L, s);
        lua_close(L);
        std::cerr << std::endl;
    }
    return 0;
}

void report_errors(lua_State *L, int status) {
    if (status) {
        std::cerr << "-- " << lua_tostring(L, -1) << std::endl;
        lua_pop(L, 1);
    }
}
#包括
#包括
#包括
#包括
无效报告错误(lua\U状态*,整数);
int main(int argc,字符**argv){
对于(int n=1;nSTR::C++中的CURR 

你应该包括<代码> Lua. Hpp不<代码> Lua. H./Cuff> <代码> Lua. h < /C> >不定义<代码>外部“C” < P>在输入文件之前,G+的参数为-LLUA。我在最后输入LULA,现在所有的工作都很好。

如果不是C++,则可以得到更多的帮助。如果使用“代码>外部”C“< /代码>()”,我不擅长阅读技术文档。你能详细说明一下吗?这是一项你必须学习的技能,而不仅仅是放弃。Google for
lua c++
的第一个结果清楚地回答了这个问题:(以下是我获取的
“luaopen\u loadlib”未在此范围内声明的
,当我删除该语句时,它会编译;但是,当我运行该语句时,lua会将
未受保护的错误发送到lua API(无调用环境)