LuaJIT FFI Library (C code from 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
User avatar
AntonioModer
Party member
Posts: 202
Joined: Fri Jun 15, 2012 5:31 pm
Location: Belarus
Contact:

LuaJIT FFI Library (C code from LuaJIT)

Post by AntonioModer »

I find awesome library in LuaJIT.
The FFI library allows calling external C functions and using C data structures from pure Lua code.
http://luajit.org/ext_ffi.html
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: LuaJIT FFI Library (C code from LuaJIT)

Post by Ranguna259 »

Wow, can we do this in LÖVE ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LuaJIT FFI Library (C code from LuaJIT)

Post by Robin »

Yes, if the build of LÖVE you're using is linked with LuaJIT instead of regular Lua. It is the default for 0.9.1, so you probably can.
Help us help you: attach a .love.
toadkick
Prole
Posts: 2
Joined: Mon Feb 17, 2014 4:27 pm

Re: LuaJIT FFI Library (C code from LuaJIT)

Post by toadkick »

FYI, yes you can take advantage of LuaJIT's FFI library (thanks to LuaJIT). I was able to successfully use the clipper FFI bindings at http://luapower.com/clipper.html. Once you build the dynamic library, simply put that and your .lua file with your FFI bindings into your project like you would any other .lua file, and

Code: Select all

local clipper = require "clipper"
Piece of cake!
User avatar
AntonioModer
Party member
Posts: 202
Joined: Fri Jun 15, 2012 5:31 pm
Location: Belarus
Contact:

Re: LuaJIT FFI Library (C code from LuaJIT)

Post by AntonioModer »

English.
Creating a dynamic link library and call the "native-C" function of this library from LuaJIT 2 (from LOVE2D).

Русский.
Создание динамической библиотеки и вызов "нативной-C" функции этой библиотеки из LuaJIT 2 (из LOVE2D)

Source files: https://drive.google.com/open?id=0BxsLw ... lBRWXpIb0U

Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests