Strange behavior with LuaJIT

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Strange behavior with LuaJIT

Post by davisdude »

Hey,

I'm trying to learn a bit of C so I can use FFI, but I'm having a bit of trouble with some things, and I was hoping somebody with more experience/technical know-how could help me out here.

I'm following this tutorial. So I started by installing gcc with Cygwin.

Everything compiles correctly with the file to the shared object. When I try to load it from the LuaJIT command line, however, it fails at this point:

Code: Select all

> ffi = require 'ffi'
> start = ffi.load( 'libfirst.so' )
stdin:1: cannot load module 'libfirst.so': %1 is not a valid Win32 application.
So then I remember, I've downloaded Cygwin (x64), but LuaJIT is (x32). So I look around and run it with the command gcc -W -Wall -g -fPIC -shared -m32 -o libfirst.so first.c, so that it compiles a 32 bit so. When I try again with LuaJIT, I get the very same error.

So then, just for kicks, I tried compiling it and running it from the Cygwin command line. With the -m32 flag, it fails with a ton of errors. Without -m32, it compiles without issue. Then, when I run LuaJIT from the command line, it works!

With LOVE, it's the same story, with even more of a twist: When I run LOVE from the command line (all compiled from the Windows command line), the file can't be found. When I run LOVE from Cygwin (all compiles from Cygwin) it works.

Anyway, it's all really bizarre, but I was hoping somebody had some insights into this problem.

Thanks
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: Strange behavior with LuaJIT

Post by Sulunia »

Btw, not related to the thread, but riding along:

If anyone knows a nice FFI 101 guide, i'd be happy to know it.

Now then.. Cygwin? Doesn't it cross compile Windows apps to Linux operating environment?
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Strange behavior with LuaJIT

Post by raidho36 »

The program will look for this binary in a few very specific directories, other than system directories that would be current working directory. I.e. in which directory you were when you started the program. With command line that's straightforward, but with GUI that gets a bit wonky - you should expect that.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Strange behavior with LuaJIT

Post by s-ol »

when you say all compiles from Cygwin what do you mean? luajit + the dll + love compiled from cygwin?
i thought compiling love on cygwin was going to be trouble, at least it was on mingw2.

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
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Strange behavior with LuaJIT

Post by davisdude »

s-ol wrote:when you say all compiles from Cygwin what do you mean?
Just the file is compiled with gcc from Cygwin, but then LOVE is run from it as well ("love ." when in the directory)
Sulunia wrote:If anyone knows a nice FFI 101 guide, i'd be happy to know it.
The link in the op has a some very basic information about FFI if that helps
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Strange behavior with LuaJIT

Post by s-ol »

Sulunia wrote: Tue Mar 28, 2017 12:30 am Btw, not related to the thread, but riding along:

If anyone knows a nice FFI 101 guide, i'd be happy to know it.

Now then.. Cygwin? Doesn't it cross compile Windows apps to Linux operating environment?
Well, the luajit page has the ffi api and a tutorial for ffi. It's not really a 101 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
Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests