Hi there. I am sitting here, preparing a projection mapping with love2d (no really, will post about the project later). For that, I want to embed a OSC (OpenSoundControl) lib into my setup. I got everything done and the OSC-lib works fine when using Lua directly from the console/Terminal. The lib I used is compiled, resulting in a .so-file. -> https://github.com/grrrwaaa/luaosc
Now I try to do the same thing in a Love2D-project. But Love won't find the lib. "error module osc not found". Even when I try to put the .so file into the paths, that Love tolds it would search - no lock (like i.e. ./osc.so or my user folder). Now my question: is it possible to load compiled libs (.so) with Love2D?
regards and keep the lua-spirit alive
Possible to link .so (compiled) libraries with require("li")
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Possible to link .so (compiled) libraries with require("
It should load them, yeah.
Love looks for them in the base write directory (so probably ~/.local/share/love), and lua looks for them in the default paths. That said, if it fails to load because of another reason (i.e. it can't find its dependencies) it usually looks the same as it not finding it at all.
Love looks for them in the base write directory (so probably ~/.local/share/love), and lua looks for them in the default paths. That said, if it fails to load because of another reason (i.e. it can't find its dependencies) it usually looks the same as it not finding it at all.
Re: Possible to link .so (compiled) libraries with require("
try this code, tell us what appears in the console
Code: Select all
local success, error = pcall(require, "li")
print("SUCCESS: " .. tostring(success) .. " ; ERROR: " .. tostring(error) )
Lua is not an acronym.
Re: Possible to link .so (compiled) libraries with require("
(Side note: print doesn't need tostring)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Possible to link .so (compiled) libraries with require("
(Side side note: concatenating does need tostring otherwise you get an error like cannot concatenate a userdata value or whatever)Nixola wrote:(Side note: print doesn't need tostring)
Lua is not an acronym.
Re: Possible to link .so (compiled) libraries with require("
(Right, my bad. Sorry for that ^^')
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Possible to link .so (compiled) libraries with require("
Lua coerces numbers into string, so concatenating a value which you are sure is a number works just fine:
Other types, like tables, functions or nil values, are not coerced and need the tostring call.
That said, print takes a variable number of arguments, and invokes tostring on each. So you could also do this:
That however will put "tabs" between each parameter, which might not be desired in some cases. But it's just fine for debugging.
For interpolating more than 1 value in a string while fine-tunning the spacing, I usually prefer string.format:
Code: Select all
print("The number " .. 3) -- works
That said, print takes a variable number of arguments, and invokes tostring on each. So you could also do this:
Code: Select all
local success, error = pcall(require, "li")
print("SUCCESS: ", success, "ERROR: ", error)
For interpolating more than 1 value in a string while fine-tunning the spacing, I usually prefer string.format:
Code: Select all
print(("SUCCESS: %s ;ERROR: %s"):format(tostring(success), tostring(error)))
When I write def I mean function.
Re: Possible to link .so (compiled) libraries with require("
Snip quoting the above:
Yeah, I forgot print takes multiple values without need for tostringing it.
I do use strformat but when debugging i forget these things.
Yeah, I forgot print takes multiple values without need for tostringing it.
I do use strformat but when debugging i forget these things.
Lua is not an acronym.
Re: Possible to link .so (compiled) libraries with require("
Hi there. It's been a while, since I have had the time to fiddle around with this code again.
By coincidence I came across a linux vs. osx topic. I heard, that .so (shared objects) work in Linux and Windows-Systems, but not on OS-X. There I need to compile it to a .dylib file format. Could this the reason that linking to the lib did now worked for me? Maybe I'll try it later this evening and report about my .dylib-test.
Meanwhile, here is some footage from our little party installation made with Love2d: http://www.nodepond.com/blog/383-projec ... 12-cologne
By coincidence I came across a linux vs. osx topic. I heard, that .so (shared objects) work in Linux and Windows-Systems, but not on OS-X. There I need to compile it to a .dylib file format. Could this the reason that linking to the lib did now worked for me? Maybe I'll try it later this evening and report about my .dylib-test.
Meanwhile, here is some footage from our little party installation made with Love2d: http://www.nodepond.com/blog/383-projec ... 12-cologne
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Possible to link .so (compiled) libraries with require("
OSX dynamic libraries normally have the .dylib extension, however Lua libraries have the .so extension on both OSX and Linux. I believe (but I'm not positive) that you do need to compile them separately on OSX and Linux.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 12 guests