[SOLVED] How to require a shared or dynamic library and possible bug

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.
User avatar
bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

[SOLVED] How to require a shared or dynamic library and possible bug

Post by bzSteve »

On my Mac, I have a project where I use luaFileSystem with require ("lfs"). My project folder has a main.lua and lfs.so. I'm running version 0.10.0. When I run this from the command line, it works fine.

Code: Select all

/Volumes/macHD/Applications/love.app/Contents/MacOS/love .
When I drag my folder and drop it on the love.app, I get this error:
Screen Shot 2016-01-27 at 11.01.45 AM.png
Screen Shot 2016-01-27 at 11.01.45 AM.png (31.21 KiB) Viewed 6363 times
I almost always run my projects without packaging them, so I don't really know the correct way to bundle my games or set up my folders. So, what is the correct way to require a library like lfs.so? Is it a bug that the default paths are set up as shown?


EDIT: Added .love file.
imageCropTest.love
(7.24 KiB) Downloaded 190 times
EDIT 2: Added .love file with lfs.dylib
imageCropTest 2.love
(11.81 KiB) Downloaded 176 times
Last edited by bzSteve on Fri Jan 29, 2016 3:12 am, edited 4 times in total.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: How to require a shared library and possible bug

Post by Doctory »

Could you post a .love file?
User avatar
bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

Re: How to require a shared library and possible bug

Post by bzSteve »

Added the .love. Thanks for checking into this, Doctory.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: How to require a shared library and possible bug

Post by s-ol »

.so files are linux shared libraries, on mac they should be .dylib I think. Where did you get the build anyway? Should be compiled with luarocks or on your own usually.

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
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How to require a shared library and possible bug

Post by bobbyjones »

You can get luafilesystem from zerobrane. Zerobrane should have the binaries for Linux,Windows and Mac.
User avatar
bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

Re: How to require a shared library and possible bug

Post by bzSteve »

I just updated the initial post with a .love that includes the lfs.dylib from Zerobrane. Now I get the error from the command line as well as from the .love. I can't remember where I got the .so but I've been using it for months without an issue.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to require a shared or dynamic library and possible bug

Post by pgimeno »

I don't have a Mac but I find it weird that the error in the image you posted refers to a .so rather than to a .dylib.

Maybe you can add ./?.dylib to the path?
User avatar
bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

Re: How to require a shared or dynamic library and possible bug

Post by bzSteve »

Thanks for helping with this, pgimeno. I modified the require path as follows:

Code: Select all

love.filesystem.setRequirePath ( "./?.dylib;" .. love.filesystem.getRequirePath() )
I still get the same error.
Screen Shot 2016-01-27 at 7.19.15 PM.png
Screen Shot 2016-01-27 at 7.19.15 PM.png (31.77 KiB) Viewed 6236 times
A couple of things bother me. As you mention, the error message does refer to ./lfs.so on my Mac and not lfs.dylib. There is no user named alex on my system. Maybe that's slime, I'm guessing. What directory should the lfs.dylib or lfs.so be placed in? It is in the same folder as the main.lua and that works from the command line. It looks like ./lfs,so should have found the file.

If I add ?.dylib to the require path, I get this error:
Screen Shot 2016-01-27 at 7.24.57 PM.png
Screen Shot 2016-01-27 at 7.24.57 PM.png (14.92 KiB) Viewed 6236 times
That doesn't make sense to me either. Does that mean that lfs.dylib was found but treated as a lua script?

Here's the .love with the modified require path.
imageCropTest 3.love
(11.84 KiB) Downloaded 167 times
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to require a shared or dynamic library and possible bug

Post by pgimeno »

I made a quick test and it didn't check for the .dylib unless I added it to package.cpath instead of using love.filesystem.setRequirePath. Not sure if that will help. Things that come to mind that you can check:

- When it works, does it use the .so or the .dylib?
- Maybe you can print package.cpath in the cases where it does work?
- Is it possible that you have more than one LÖVE installed, and that it fails only with one of them?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How to require a shared or dynamic library and possible bug

Post by bobbyjones »

Oh yeah cpath is different from setRequirePath
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 216 guests