[Csnd] Is luajit FFI supposed to work in Windows?
Date | 2013-07-12 14:55 |
From | Mark Brophy |
Subject | [Csnd] Is luajit FFI supposed to work in Windows? |
I'm getting an "attempt to index global 'ffi' (a nil value)" from luajit after a require ffi statement that produced no error. Is FFI supposed to work under Windows? I want to develop under Windows and later port to Android. |
Date | 2013-07-12 15:13 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
I can verify that LuaJIT works with Windows XP, 7 and 8 and with Android from at least 2.3.3 on up to current versions, as I package LuaJIT with Csound for Windows and Android. You will need to build it from source for your platform and you will need to be careful about LUA_PATH and LUA_CPATH environment veriables. Recently an error was introduced into the Csound build system, testing for Lua 5.2. I fixed this a day or so ago. You should only enable Lua features for Csound using LuaJIT, not standard Lua. Hope this helps, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 9:55 AM, Mark Brophy <mark@brophyworld.com> wrote: I'm getting an "attempt to index global 'ffi' (a nil value)" from luajit after a require ffi statement that produced no error. Is FFI supposed to work under Windows? I want to develop under Windows and later port to Android. |
Date | 2013-07-12 15:57 |
From | Mark Brophy |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
I need to build luijit for Windows 8 even though it's already in the distribution? On Fri, Jul 12, 2013 at 8:13 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-12 16:18 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
No, you can use the one in the distribution. It just tested it with a fresh install of Csound 6 from the latest Windows installer, and it works for me, both the Lua opcodes, and the Lua wrappers for the Csound API.lua. However, some of the Lua examples need to change "luaCsnd" to "luaCsnd6". I will fix that. Hope this helps, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 10:57 AM, Mark Brophy <mark@brophyworld.com> wrote: I need to build luijit for Windows 8 even though it's already in the distribution? |
Date | 2013-07-12 19:15 |
From | Mark Brophy |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
The code line that isn't working on my system with LuaJIT is: local csoundApi = ffi.load('csound64') csound64.dll is in my csound6\bin directory and LUA_PATH = C:\Program Files (x86)\csound6\bin;C:\Program Files (x86)\Lua\5.1\lua\?.luac
I also have Lua 5.1 installed as indicated by LUA_PATH and Csound 5.18 installed elsewhere. What am I doing wrong?
On Fri, Jul 12, 2013 at 9:18 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-12 19:36 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
There is an error in your LUA_PATH. It should be C:\Program Files (x86)\csound6\bin\?.lua; etc. Also set LUA_CPATH to; C:\Program Files (x86)\csound6\bin\?.dll; etc.
These are case-sensitive. If you want the Lua opcodes, uninstall Lua 5.1 and use only the LuaJIT that comes with Csound. This is a drop in replacement for Lua 5.1 (and of course runs faster and has FFI).
Hope this helps, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 2:15 PM, Mark Brophy <mark@brophyworld.com> wrote: The code line that isn't working on my system with LuaJIT is: |
Date | 2013-07-12 20:35 |
From | Mark Brophy |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
I changed LUA_PATH and LUA_CPATH as you instructed but I still get the same error. My statements are: local ffi = require('ffi') local csoundApi = ffi.load('csound64')
The error message is, "attempt to index global 'ffi' (a nil value)" Why does it think that ffi is global when I declared it local? Even though I received no error message on the "require" statement, that seems as if it might be the problem.
On Fri, Jul 12, 2013 at 12:36 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-12 20:52 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
It sounds like your local variable 'ffi' is nil. Print its value to make sure. If it is nil then you are running Lua, not LuaJIT. ffi is built in to LuaJIT and does not need a path. Run LuaJIT and it should work.
Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 3:35 PM, Mark Brophy <mark@brophyworld.com> wrote: I changed LUA_PATH and LUA_CPATH as you instructed but I still get the same error. My statements are: |
Date | 2013-07-12 21:19 |
From | francesco |
Subject | [Csnd] Re: Is luajit FFI supposed to work in Windows? |
And i guess that local require is working only if in a scripts and not using interactive Lua. I guess ... never sure. ciao, francesco. -- View this message in context: http://csound.1045644.n5.nabble.com/Is-luajit-FFI-supposed-to-work-in-Windows-tp5725458p5725495.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-07-12 21:21 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: Is luajit FFI supposed to work in Windows? |
Variables should be declared local in LuaJIT if possible because they are faster than global variables. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 4:19 PM, francesco <ilterzouomo@fastwebnet.it> wrote: And i guess that local require is working only if in a scripts and not |
Date | 2013-07-12 21:30 |
From | francesco |
Subject | [Csnd] Re: Is luajit FFI supposed to work in Windows? |
Yes but if i use lua/luajit in command line (in terminal interactively) i cannot use: local csound = require ("luaCsnd") or any other module. It needs to be global. Not so when used in script. ciao, francesco. -- View this message in context: http://csound.1045644.n5.nabble.com/Is-luajit-FFI-supposed-to-work-in-Windows-tp5725458p5725497.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-07-12 21:35 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: Is luajit FFI supposed to work in Windows? |
If it is csound 6 it should be luaCsnd6. On Jul 12, 2013 4:30 PM, "francesco" <ilterzouomo@fastwebnet.it> wrote:
Yes but if i use lua/luajit in command line (in terminal interactively) i |
Date | 2013-07-12 21:40 |
From | Mark Brophy |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
I'm running LuaJIT 2.0.1 interactively and "ffi' is nil. Francesco's solution works in interactive mode; if I change ffi from local to global, no error is produced. However, if I run it in a script, I get the error, "This application has requested the Runtime to terminate it in an unusual way." On Fri, Jul 12, 2013 at 1:52 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-12 21:50 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
Wow. But that makes sense, I guess, since local variables would go out of scope on each line. Here I get the following, which I think proves this: C:\Program Files (x86)\Csound6\bin>luajit
LuaJIT 2.0.2 -- Copyright (C) 2005-2013 Mike Pall. http://luajit.org/ JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse > local ffi = require("ffi")
> print(ffi) nil > ffi = require("ffi") > print(ffi) table: 0x002b9058 > =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 4:40 PM, Mark Brophy <mark@brophyworld.com> wrote: I'm running LuaJIT 2.0.1 interactively and "ffi' is nil. Francesco's solution works in interactive mode; if I change ffi from local to global, no error is produced. However, if I run it in a script, I get the error, "This application has requested the Runtime to terminate it in an unusual way." |
Date | 2013-07-12 21:52 |
From | Michael Gogins |
Subject | Re: [Csnd] Is luajit FFI supposed to work in Windows? |
Oh yes, and I get: > csound = require('luaCsnd6') > print(csound) table: 0x002ba560 =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 12, 2013 at 4:50 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-12 22:02 |
From | francesco |
Subject | [Csnd] Re: Is luajit FFI supposed to work in Windows? |
yea ... now i feel so smart:) ciao, francesco. -- View this message in context: http://csound.1045644.n5.nabble.com/Is-luajit-FFI-supposed-to-work-in-Windows-tp5725458p5725502.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-07-12 22:19 |
From | francesco |
Subject | [Csnd] Re: Is luajit FFI supposed to work in Windows? |
Just a shot in the dark, but i see You are using LuaJIT 2.0.1 while it seems that Mr. Gogins bundled LuaJIT 2.0.2 with Csound6; could be this? Maybe do You have another LuaJIT somewhere? ciao, francesco. -- View this message in context: http://csound.1045644.n5.nabble.com/Is-luajit-FFI-supposed-to-work-in-Windows-tp5725458p5725505.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-07-12 22:51 |
From | Mark Brophy |
Subject | Re: [Csnd] Re: Is luajit FFI supposed to work in Windows? |
I'm using LuaJIT from the Csound distribution in the ..\bin directory but I'm a few release candidates behind the official release. Fixing the paths now allows me to run the csound_ffi.lua file without errors until the strange abort message at the end, "terminate in an unusual way." On Fri, Jul 12, 2013 at 3:19 PM, francesco <ilterzouomo@fastwebnet.it> wrote: Just a shot in the dark, but i see You are using LuaJIT 2.0.1 while it seems |
Date | 2013-07-12 23:39 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: Is luajit FFI supposed to work in Windows? |
This is a bug in the Lua opcodes moduleDestroy function that we can thank Steven Yi for fixing a few days ago. On Jul 12, 2013 5:51 PM, "Mark Brophy" <mark@brophyworld.com> wrote:
I'm using LuaJIT from the Csound distribution in the ..\bin directory but I'm a few release candidates behind the official release. Fixing the paths now allows me to run the csound_ffi.lua file without errors until the strange abort message at the end, "terminate in an unusual way." |