Luajit Compiling lua-lzma on windows mingw64

so i have a project where i need lzma decompression so i googled and found this project https://github.com/rainfiel/lua-lzma
After some trick I managed to compile it to find it was written for lua 5.2 so I changed some lines to fix this. In the file llzma.c, I changed the line luaL_newlib(L, l);

to luaL_register(L, "lzma", l);

, commented out luaL_checkversion(L);

and changed size_t len = lua_rawlen(L, 1);

to size_t len = lua_objlen(L, 1);

, etc.

My makefile looks something like this.

all: lzma.dll

lzma.dll: LzFind.o LzAlloc.o LzmaDec.o LzmaEnc.o LzmaLib.o llzma.o
    gcc -O -shared -o lzma.dll llzma.o LzmaLib.o LzmaEnc.o LzmaDec.o 
LzFind.o LzAlloc.o -L"..\bin" -llua51

LzFind.o: LzFind.c
    gcc -O2 -c LzFind.c 
LzAlloc.o: LzAlloc.c
    gcc -O2 -c LzAlloc.c 
LzmaDec.o: LzmaDec.c
        gcc -O2 -c LzmaDec.c 
LzmaEnc.o: LzmaEnc.c
    gcc -O2 -c LzmaEnc.c 
LzmaLib.o: LzmaLib.c    
    gcc -O2 -c LzmaLib.c 
llzma.o:   llzma.c
    gcc -I..\luajit\src\src -O2 -c -o llzma.o llzma.c

      

I got it to compile, but when I try to download it I should get this message:

> require 'lzma'
error loading module 'lzma' from file '.\lzma.dll':
    The specified procedure could not be found.

stack traceback:
    [C]: at 0x66dd6c40
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: at 0x00401f80

      

I did some more searches and came across this http://lua-users.org/lists/lua-l/2013-03/msg00363.html
However, when I did the dump, the luaopen_lzma function was there, so it looks like it was exported. I'm totally here. I don't have much experience with binary libraries and the like, so this worries me. I would like to be able to compile and use this library rather than writing myself. Does anyone know what I am doing wrong?

+3


source to share


1 answer


I solved my problem, originally I compiled and forgot to link llzma.c, so it didn't have any lua api code, I put it next to the binary in the folder, but it didn't see the dll and didn't load it, so I put it to the working directory and it seemed to work. from that point on I put it in the working directory and left the old one in the bin folder and from that point on it seems to find the dll in the bin folder and load from it. So when I removed it from the bin folder it worked ...
So it was a complete failure and oversight on my part, sorry for the time everybody used to help me with my problems, it just shows how inexperienced I am when it comes down to it.



0


source







All Articles