lua-users home
lua-l archive

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


Hello. I'm new in the list. I'm try to static link lua with my app like
this:

cc -std=c99 -O0 -ggdb  -static  -static-libgcc -o embed embed.c
-I/usr/include/lua5.1  -L/usr/lib64   -llua5.1 -lm -ldl -lc


Linking brings warning. How can I avoid this and what it mean for me if
i want to build fully static binary, that can be running inside initrd
with no libraries?



embed.c: In function ‘enm_httprequest’:
embed.c:15:11: warning: assignment discards qualifiers from pointer
target type
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/liblua5.1.a(loadlib.o): in function ll_loadfunc:loadlib.c(.text+0x909): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

vase@selfip ~/projects/elasticm/src $ cat embed.c 
#include <stdlib.h>
#include <stdio.h>

/* Include the Lua API header files. */
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>


static int enm_httprequest(lua_State *L) {
        int n = lua_gettop(L);
        char *request;
        char *response = "response";
        for ( int i=0; i <= n; i++ ) {
                request = lua_tostring(L, i); 
        }

        lua_pushstring(L, response);
        printf("result C: %s\n", request);
        return 1;
}

int main(int argc, char **argv, char **envp) {
        lua_State* L;

        L = lua_open();

        luaL_openlibs(L); 

        lua_register(L, "enm_httprequest", enm_httprequest); 

        luaL_dofile(L, "embed.lua");

        lua_close(L); 

        return 0;
}


-- 
Vasiliy G Tolstov <v.tolstov@selfip.ru>
Selfip.Ru