Page 1 of 2

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

Posted: Wed Jan 27, 2016 7:10 pm
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 6657 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 221 times
EDIT 2: Added .love file with lfs.dylib
imageCropTest 2.love
(11.81 KiB) Downloaded 187 times

Re: How to require a shared library and possible bug

Posted: Wed Jan 27, 2016 7:21 pm
by Doctory
Could you post a .love file?

Re: How to require a shared library and possible bug

Posted: Wed Jan 27, 2016 7:29 pm
by bzSteve
Added the .love. Thanks for checking into this, Doctory.

Re: How to require a shared library and possible bug

Posted: Wed Jan 27, 2016 7:55 pm
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.

Re: How to require a shared library and possible bug

Posted: Wed Jan 27, 2016 8:26 pm
by bobbyjones
You can get luafilesystem from zerobrane. Zerobrane should have the binaries for Linux,Windows and Mac.

Re: How to require a shared library and possible bug

Posted: Wed Jan 27, 2016 8:39 pm
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.

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

Posted: Thu Jan 28, 2016 1:07 am
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?

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

Posted: Thu Jan 28, 2016 3:27 am
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 6530 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 6530 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 181 times

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

Posted: Thu Jan 28, 2016 5:19 am
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?

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

Posted: Thu Jan 28, 2016 5:56 am
by bobbyjones
Oh yeah cpath is different from setRequirePath