Page 1 of 1

Require .so - Wrong Architecture

Posted: Sun Dec 20, 2009 4:06 am
by 10Print
I'm having issues loading external libraries into Love.
For example, I have lrandom compiled to "/usr/local/lib/lua/5.1/random.so".
In plain old lua require("random") works fine, but when I try and do the same thing in Love, I get this error:

Code: Select all

function love.load()
    require("random")
end

Code: Select all

error loading module 'random' from file '/usr/local/lib/lua/5.1/random.so': 
dlopen(/usr/local/lib/lua/5.1/random.so, 2): no suitable image found. 
Did find: /usr/local/lib/lua/5.1/random.so: mach-o, but wrong architecture
Thoughts? (This happens with both Love 5 and 6... I'm on OS X 10.6.2 and have Lua 5.1.4 installed.)

Re: Require .so - Wrong Architecture

Posted: Sun Dec 20, 2009 5:47 am
by bmelts
The problem is exactly what OS X reported to you: lrandom is the wrong architecture. LÖVE is a 32-bit app on Mac OS X, and it can't load a library that's been compiled in 64-bit mode, as lrandom almost certainly was if you compiled it on Snow Leopard.

In the absence of a 64-bit love.app (I'd have to redo most of the frameworks to make that possible, since I don't think any of them have 64-bit architectures included - this is a future project), you'll need to recompile lrandom in 32-bit mode for it to be usable.

Also keep in mind that external libraries are not usable from within the .love file at this point, due to limitations with PhysFS. So if you wanted to distribute a LÖVE game that used lrandom, you'd need to make sure your users have it installed prior to running your game.