lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I tried the suggested changes, but the original test script worked fine while this gave me the following error:

 

C:\Users\name\AppData\Local\Temp\ccGhaL5y.o: In function `main':

C:/Users/name/Desktop/Apps/test/embed.c:62:warning: implicit declaration of function 'luaL_setfuncs'; did you mean 'lua_setfenv'? [-Wimplicit-function-declaration]

  luaL_setfuncs(L,preloaders,0);

  ^~~~~~~~~~~~~

  lua_setfenv

 

C:\Users\name\AppData\Local\Temp\ccGhaL5y.o: In function `main':

C:/Users/name

/Desktop/Apps/test/embed.c:62: undefined reference to `luaL_setfuncs

'

collect2.exe: error: ld returned 1 exit status

 

 

From: Sean Conner
Sent: Monday, October 25, 2021 3:28 AM
To: Lua mailing list
Subject: Re: I Can't Get Lua 5.1 and IUP 3.30 to Work With VSCode and GCC on Windows 10 x64

 

It was thus said that the Great nerditation once stated:

> On 2021/10/24 5:18, Kaz wrote:

> >

> > What should I put into the files to test?

>

> try this piece of code which demonstrates the usage of Lua and iuplua from

> C. this should be copy-paste ready.

>

> ```C

> #include <stdio.h>

>

> #include <lua.h>

> #include <lualib.h>

> #include <lauxlib.h>

>

> #include <iup.h>

> #include <iuplua.h>

>

 

  Starting from here:

 

> typedef struct {

>    char const *name;

>    lua_CFunction loaderfn;

> } Preloader;

>

> /* list the Lua modules you want to preload here */

> static const Preloader preloaders[] = {

>    { "iuplua", &iuplua_open },

>    { NULL, NULL },

> };

 

to here, can be replaced with:

 

       static luaL_Reg const preloaders[] =

       {

         { "iuplua" , &iuplua_open },

          { NULL     , NULL         }

       };

 

> int main(int argc, char const *argv[])

> {

>    /* do something in C */

>    printf("hello C!\n");

>

>    /* init Lua runtime */

>    lua_State *L = luaL_newstate();

>    luaL_openlibs(L);

>

>    /* try run some Lua code */

>    luaL_dostring(L, "print 'hello Lua!'");

>

>    /* install preloaders into package.preload */

>    lua_getglobal(L, "package");

>    lua_getfield(L, -1, "preload");

 

  And from here:

 

>    Preloader const *mod = &preloaders[0];

>    while (mod->name != NULL) {

>           lua_pushcfunction(L, mod->loaderfn);

>           lua_setfield(L, -2, mod->name);

>           ++mod;

>    }

 

to here, replace with:

 

       luaL_setfuncs(L,preloaders,0);

 

>       lua_pop(L,2);

>    /* try run some more Lua code with iup */

>    luaL_dostring(L, "local iup = require 'iuplua'; iup.Message('hello', 'hello iuplua!');");

>

>    lua_close(L);

>    return 0;

> }

> ```

 

  Just FYI.

 

  -spc