GifCat -- Write GIFs in LOVE.

Showcase your libraries, tools and other projects that help your fellow love users.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock » Wed Sep 14, 2016 12:49 pm

You will need to insall the luajit dynamic library and put it in your PATH so it it can link against it. I don't run windows so that is the most I can help, I'm sorry. I would start here to figure it out: http://luajit.org/install.html

GodotMisogi
Prole
Posts: 4
Joined: Mon Dec 26, 2016 7:36 am

Re: GifCat -- Write GIFs in LOVE.

Post by GodotMisogi » Mon Dec 26, 2016 7:43 am

Hi, I'd made the following modifications to build.py to get mingw to compile gifcatlib.dll on Windows:

Code: Select all

import os, sys, platform, string


opt = {
    "compiler"  : "gcc",
    "source"    : "src/lua_bindings.c",
    "link"      : "",
    "include"   : "",
    "flags"     : "-O2 -pedantic -Wall -Wextra -std=c99",
    "outfile"   : "-o gifcatlib.dll",
    "define"    : "",
}

template = "$compiler $outfile $source $include $link $flags $define"

if platform.system() == "Windows":
    opt["flags"] += " [color=#FF0000]-llua[/color] -fpic -shared"
    opt["link"] += " -lws2_32"

elif platform.system() == "Darwin":
    opt["flags"] += " -bundle -undefined dynamic_lookup"

else: # Assume Linux, BSD etc.
    opt["flags"] += " -fpic -shared"


print(string.Template(template).substitute(opt))
os.system(string.Template(template).substitute(opt))
[color=#FF0000]print(platform.system())[/color]
This generates the following output:

Code: Select all

$ python build.py
gcc -o gifcatlib.dll src/lua_bindings.c   -lws2_32 -O2 -pedantic -Wall -Wextra
-std=c99 -llua -fpic -shared
src/lua_bindings.c:1:0: warning: -fpic ignored for target (all code is position
 independent)
 /*
 ^
In file included from src/lua_bindings.c:31:0:
src/jo_gif.c: In function 'jo_gif_quantize':
src/jo_gif.c:88:18: warning: ISO C forbids empty initializer braces [-Wpedantic
]
  int bias[256] = {}, freq[256];
                  ^
src/jo_gif.c: In function 'jo_gif_lzw_encode':
src/jo_gif.c:227:2: warning: missing initializer for field 'buf' of 'jo_gif_lzw
_t' [-Wmissing-field-initializers]
  jo_gif_lzw_t state = {fp, 9};
  ^
src/jo_gif.c:204:16: note: 'buf' declared here
  unsigned char buf[256];
                ^
src/jo_gif.c: In function 'jo_gif_start':
src/jo_gif.c:287:17: warning: ISO C forbids empty initializer braces [-Wpedanti
c]
  jo_gif_t gif = {};
                 ^
src/jo_gif.c:287:2: warning: missing initializer for field 'fp' of 'jo_gif_t' [
-Wmissing-field-initializers]
  jo_gif_t gif = {};
  ^
In file included from src/lua_bindings.c:31:0:
src/jo_gif.c:28:8: note: 'fp' declared here
  FILE *fp;
        ^
Windows
So the dll file is built. I altered gifcat.lua's

Code: Select all

local GIFLIB = "gifcatlib.dll"
and placed the dll and gifcat.lua in the base folder. My lua interpreter throws the following error: "Thread error!
gifcat.lua:188: %1 is not a valid Win32 application."

I'm not really sure what to do now. Any help?

User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by s-ol » Mon Dec 26, 2016 1:09 pm

GodotMisogi wrote:Hi, I'd made the following modifications to build.py to get mingw to compile gifcatlib.dll on Windows:

Code: Select all

import os, sys, platform, string


opt = {
    "compiler"  : "gcc",
    "source"    : "src/lua_bindings.c",
    "link"      : "",
    "include"   : "",
    "flags"     : "-O2 -pedantic -Wall -Wextra -std=c99",
    "outfile"   : "-o gifcatlib.dll",
    "define"    : "",
}

template = "$compiler $outfile $source $include $link $flags $define"

if platform.system() == "Windows":
    opt["flags"] += " [color=#FF0000]-llua[/color] -fpic -shared"
    opt["link"] += " -lws2_32"

elif platform.system() == "Darwin":
    opt["flags"] += " -bundle -undefined dynamic_lookup"

else: # Assume Linux, BSD etc.
    opt["flags"] += " -fpic -shared"


print(string.Template(template).substitute(opt))
os.system(string.Template(template).substitute(opt))
[color=#FF0000]print(platform.system())[/color]
This generates the following output:

Code: Select all

$ python build.py
gcc -o gifcatlib.dll src/lua_bindings.c   -lws2_32 -O2 -pedantic -Wall -Wextra
-std=c99 -llua -fpic -shared
src/lua_bindings.c:1:0: warning: -fpic ignored for target (all code is position
 independent)
 /*
 ^
In file included from src/lua_bindings.c:31:0:
src/jo_gif.c: In function 'jo_gif_quantize':
src/jo_gif.c:88:18: warning: ISO C forbids empty initializer braces [-Wpedantic
]
  int bias[256] = {}, freq[256];
                  ^
src/jo_gif.c: In function 'jo_gif_lzw_encode':
src/jo_gif.c:227:2: warning: missing initializer for field 'buf' of 'jo_gif_lzw
_t' [-Wmissing-field-initializers]
  jo_gif_lzw_t state = {fp, 9};
  ^
src/jo_gif.c:204:16: note: 'buf' declared here
  unsigned char buf[256];
                ^
src/jo_gif.c: In function 'jo_gif_start':
src/jo_gif.c:287:17: warning: ISO C forbids empty initializer braces [-Wpedanti
c]
  jo_gif_t gif = {};
                 ^
src/jo_gif.c:287:2: warning: missing initializer for field 'fp' of 'jo_gif_t' [
-Wmissing-field-initializers]
  jo_gif_t gif = {};
  ^
In file included from src/lua_bindings.c:31:0:
src/jo_gif.c:28:8: note: 'fp' declared here
  FILE *fp;
        ^
Windows
So the dll file is built. I altered gifcat.lua's

Code: Select all

local GIFLIB = "gifcatlib.dll"
and placed the dll and gifcat.lua in the base folder. My lua interpreter throws the following error: "Thread error!
gifcat.lua:188: %1 is not a valid Win32 application."

I'm not really sure what to do now. Any help?
I'm not sure but I think it might be that the mingw dll will only work with a mingw-compiled LÖVE, and I'm not sure whether that will work out with SDL on windows. I can be completely off here though.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end

User avatar
pgimeno
Party member
Posts: 2219
Joined: Sun Oct 18, 2015 2:58 pm

Re: GifCat -- Write GIFs in LOVE.

Post by pgimeno » Mon Dec 26, 2016 7:28 pm

Check also if you were cross-compiling for 32 bits in a 64 bit machine or vice versa. And I'd try also removing ".dll".

WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock » Wed Dec 28, 2016 6:13 am

Yeah, thats also a bizarro error message. Can you show me a unified diff of what you did to the build.py? I'm on mac so I have a limited amount of things that I can do.

GodotMisogi
Prole
Posts: 4
Joined: Mon Dec 26, 2016 7:36 am

Re: GifCat -- Write GIFs in LOVE.

Post by GodotMisogi » Thu Dec 29, 2016 7:52 am

Since colours don't work in <code>, I added capitalised comments of the changes I made in braces to this post. I'm also building using Python 3.5. I'll also note that exclusion of

Code: Select all

opt["link"] += " -lws2_32"
makes no difference during the build.

Code: Select all

#!/usr/bin/python2.7

import os, sys, platform, string


opt = {
    "compiler"  : "gcc",
    "source"    : "src/lua_bindings.c",
    "link"      : "",
    "include"   : "",
    "flags"     : "-O2 -pedantic -Wall -Wextra -std=c99",
    "outfile"   : "-o gifcatlib.dll (CHANGED OUTPUT TO .DLL FROM .SO)",
    "define"    : "",
}

template = "$compiler $outfile $source $include $link $flags $define"

if platform.system() == "Windows":
    opt["flags"] += " -llua (ADDED LUA LINKER) -fpic -shared"
    opt["link"] += " -lws2_32"

elif platform.system() == "Darwin":
    opt["flags"] += " -bundle -undefined dynamic_lookup"

else: # Assume Linux, BSD etc.
    opt["flags"] += " -fpic -shared"


print(string.Template(template).substitute(opt))
os.system(string.Template(template).substitute(opt))
print(platform.system()) -- DEBUGGING BY CHECKING OS 

WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock » Sun Jan 01, 2017 7:38 am

You shouldn't need to link to lua. Why did you link it to Lua?

GodotMisogi
Prole
Posts: 4
Joined: Mon Dec 26, 2016 7:36 am

Re: GifCat -- Write GIFs in LOVE.

Post by GodotMisogi » Sun Jan 01, 2017 11:46 am

Without that linker, I get the same undefined reference errors that PixelPiledriver was getting.

WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock » Sun Jan 01, 2017 6:05 pm

I believe that error would've been solved by making it so the compiler could find lua.h. Not sure why -llua would fix that. IIRC I heard once that while you can link lua libraries to lua, you shouldn't.

GodotMisogi
Prole
Posts: 4
Joined: Mon Dec 26, 2016 7:36 am

Re: GifCat -- Write GIFs in LOVE.

Post by GodotMisogi » Mon Jan 02, 2017 7:32 am

I was following this tutorial to see how to fix the undefined reference errors, and it adds -llua:

https://csl.name/post/lua-and-cpp/

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests