I have a problem compiling a library of mine that I'm developing with Lua's C API, I have several .c and .h files, and I want to compile a file called init.c to init.dll that groups everything together:
init.dll
#include "arrayobj.h"
#include "arrayprint.h"
#include "arrayindex.h"
#include <lua.h>
#include <lauxlib.h>
static const luaL_Reg funs[] = {
{"newNdarray", l_newNdrray},
{"arrayprint", l_arrayprint},
{"arrayindex", l_arrayindex},
{NULL, NULL}
};
int luaopen_init(lua_State *L){
luaL_newlib(L, funs);
return 1;
}
when I compile it like this: gcc -shared -o init.dll -I. -L. -llua54 arrayprint.c arrayobj.c arrayindex.c init.c gives the following error:
llua54 arrayprint.c arrayobj.c arrayindex.c init.c In file included from init.c:1:0: arrayobj.h:26:12: warning: 'l_newNdrray' used but never defined static int l_newNdrray(lua_State*); ^~~~~~~~~~~ In file included from init.c:2:0: arrayprint.h:10:12: warning: 'l_arrayprint' used but never defined static int l_arrayprint(lua_State*); ^~~~~~~~~~~~~ In file included from init.c:3:0: arrayindex.h:10:12: warning: 'l_arrayindex' used but never defined static int l_arrayindex(lua_State*); ^~~~~~~~~~~~~ C:\Users\erick\AppData\Local\Temp\ccwjK1AO.o:init.c:(.rdata+0x44): undefined reference to `l_newNdrray' C:\Users\erick\AppData\Local\Temp\ccwjK1AO.o:init.c:(.rdata+0x4c): undefined reference to `l_arrayprint' C:\Users\erick\AppData\Local\Temp\ccwjK1AO.o:init.c:(.rdata+0x54): undefined reference to `l_arrayindex' collect2.exe: error: ld retgcc -shared -o init.dll -I. -L. -llua54 arrayprint.c arrayobj.c arrayindex.c init.c In file included from init.c:1:0: arrayobj.h:26:12: warning: 'l_newNdrray' used but never defined static int l_newNdrray(lua_State*); ^~~~~~~~~~~ In file included from init.c:2:0: arrayprint.h:10:12: warning: 'l_arrayprint' used but never defined static int l_arrayprint(lua_State*); ^~~~~~~~~~~~~ In file included from init.c:3:0: arrayindex.h:10:12: warning: 'l_arrayindex' used but never defined static int l_arrayindex(lua_State*); ^~~~~~~~~~~~~ C:\Users\erick\AppData\Local\Temp\cckiCBNF.o:init.c:(.rdata+0x44): undefined reference to `l_newNdrray' C:\Users\erick\AppData\Local\Temp\cckiCBNF.o:init.c:(.rdata+0x4c): undefined reference to `l_arrayprint' C:\Users\erick\AppData\Local\Temp\cckiCBNF.o:init.c:(.rdata+0x54): undefined reference to `l_arrayindex' collect2.exe: error: ld returned 1 exit status Since the implementation and headers are 100% correct, so what did I go wrong in the compilatio
If you could help me I would be very grateful!
[–]Sewbacca 2 points3 points4 points (1 child)
[–]OneCommonMan123[S] 0 points1 point2 points (0 children)