Does LuaRocks rockspec use only file names for module sub-names? - lua

Is it normal for LuaRocks to ignore the module name in a rockspec, using the filename instead?
build = {
type = "builtin",
modules = {
apricot = "src/apricot.lua",
["apricot.stuff"] = "src/apricot/seeds.lua",
-- `apricot.stuff` is renamed to `apricot.seeds`
-- when installed as a rock.
}
}
(Lua 5.1, LuaRocks 2.1.0)

Yes, it was a bug. I just pushed a fix:
https://github.com/keplerproject/luarocks/commit/0b8605f5d53a9fef54ca17bf5447132327b0ae6e
Please let me know (preferably in the bug tracker) if there are any problems with this fix. Thank you!

Related

Luarocks on windows not recognizing my lua_libdir

i want to install nngraph on lua using luarocks
using this code
luarocks --from=https://raw.githubusercontent.com/torch/rocks/master/ install nngraph
but it's give me an error
it said :
Error: Failed finding Lua library. You may need to configure LUA_LIBDIR.
does anyone have same experience? can you solve it ?
this was my config-5.2.lua :
rocks_trees = {
{ name = [[user]],
root = home..[[/luarocks]],
},
{ name = [[system]],
root = [[d:\shared\ta\_bootstrap\_install\]],
},
}
variables = {
MSVCRT = 'MSVCRT',
LUALIB = 'D:\\Shared\\TA\\_bootstrap\\_install\\lib\\liblua.dll.a',
LUA_LIBDIR = 'D:\\Shared\\TA\\_bootstrap\\_install\\lib'
}
verbose = false -- set to 'true' to enable verbose output
Is your config-5.2.lua file located in one of the searched paths? I installed the stand-alone binaries (with Lua version 5.3), which searches for C:/Program Files (x86)/luarocks/config-5.3.lua & %APPDATA%/luarocks/config-5.3.lua. Neither of these files existed on my system & I had to create one manually. Running the luarocks command without any arguments will show you where it searches. If you want to use a custom location, you can set the LUAROCKS_CONFIG environment variable.
I was able to get mine working by adding the following variables to my configuration (Note: I am using MinGW/GCC compiler):
rocks_trees = {
{ name = [[system]], root = [[C:/Development/Lua53]] },
}
variables = {
LUA = 'C:/Development/Lua53/bin/lua',
LUA_BINDIR = 'C:/Development/Lua53/bin',
LUA_INCDIR = 'C:/Development/Lua53/include',
LUA_LIBDIR = 'C:/Development/Lua53/lib',
CC = 'gcc',
LD = 'gcc',
}
The CC & LD variables are only necessary if it has trouble finding the compiler or linker (defaults to mingw32-gcc on my system).
Sources:
http://lua-users.org/wiki/LuaRocksConfig
http://lua-users.org/lists/lua-l/2015-12/msg00172.html
https://github.com/luarocks/luarocks/wiki/config-file-format
I hope this helps.
Edit: If all else fails, you may want to have a look at LuaDist. It is a Lua distribution with its own package management system & includes LuaRocks & some other libraries/utilities pre-installed. I haven't tried it yet, but I plan to.

VCLua library fault to load

I have downloaded VCLua library here. I created new file named program.lua and typed there code that is in tutorial:
require "vcl"
mainForm = VCL.Form("mainForm")
mainForm.Caption = "My first VCLua application"
mainForm._= { position="podesktopcenter", height=400, width=600}
mainForm.onclosequery = "onCloseQueryEventHandler"
function onCloseQueryEventHandler(Sender)
return true -- the form can be closed
end
mainMenu = VCL.MainMenu(mainForm,"mainMenu")
mainMenu:LoadFromTable({
{name="mmfile", caption="&File",
submenu={
{name="mmOpen", caption="Open...", onclick="onMenuOpenClick", shortcut="Ctrl+O"},
{caption="-",},
{caption="Exit", onclick="onMenuExitClick", shortcut="Alt+F4"},
}
},
{name="mmhelp", caption="&Help", RightJustify=true,
submenu = {
{caption="Help", shortcut="F1", checked=true},
{caption="-",},
}
}
})
mainMenu:Find("mmhelp"):Add("mmAbout")._= {caption="About", onclick="onMenuAboutClick", enabled=false}
function onMenuExitClick()
mainForm:Close()
end
mainToolbar = VCL.ToolBar(mainForm,"mainToolbar")
mainToolbar:LoadFromTable({
{name="mtbOpen", onclick="onMenuOpenClick"},
{name="mtbExit", onclick="onMenuExitClick"},
})
mainToolbar:Find("mtbOpen").enabled=false
mainForm:ShowModal()
mainForm:Free()
But when i want to run it (i have both vcl.dll and vcl.so files in directory where lua interpreter is), it writes lua: error loading module 'vcl' from file 'C:\Users\Admin\Desktop\Programs\lua\vcl.dll':. Stack trace dont say anything useful. So can anyone tell me, how to solve my problem?
Dynamic libraries for Lua are usually compiled against Lua DLLs; you may get this error in a case when the dynamic library can't find the Lua DLLs it's linked against. You can see why/how it fails using a tool like dependency walker, which can show you both what other DLLs your library depends on and also what run-time error you get when you load it (you can use "Profile" mode to see that).

iOS CommonJS module returns "undefined is not a constructor" error

I'm trying to create an iOS Titanium Module using a pre-compiled CommonJS module. As the README file says:
All JavaScript files in the assets directory are IGNORED except if you create a
file named "com.moduletest.js" in this directory in which case it will be
wrapped by native code, compiled, and used as your module. This allows you to
run pure JavaScript modules that are pre-compiled.
I've created the file like this:
function ModuleTest(url){
if(url){
return url;
}
}
exports.ModuleTest = ModuleTest;
I'm using the 5.1.2.GA SDK (also tried with 5.3.0.GA) and I can build the module successfully either with python build.py or titanium build --platform iOS --build-only.
Then, in my test app doing:
var test = require('com.moduletest');
var url = new test.ModuleTest('http://url');
Gives me this error:
undefined is not a constructor.
I've been trying a lot of alternatives but nothing seems to work and I didn't find any help on documentation about pre-compiled JS modules for iOS. Actually, the same process works great for Android!
Do you have some idea why?
My environment:
XCode 7.3.1
Operating System
Name - Mac OS X
Version - 10.11.5
Architecture - 64bit
# CPUs - 8
Memory - 16.0GB
Node.js
Node.js Version - 0.12.7
npm Version - 2.11.3
Appcelerator CLI
Installer - 4.2.6
Core Package - 5.3.0
Titanium CLI
CLI Version - 5.0.9
node-appc Version - 0.2.31
Maybe this is something related to my Node version or appc CLI, not sure =/
Thank you!
There are 2 solutions.
1) Don't put it in assets, but in the /app/lib folder as others have mentioned.
2) wrap it as an actual commonjs module, like the module I wrote
In both cases, you can just use require('modulename'). In case 2 you will need to add it to the tiapp.xml file just like any other module.
The path of your file will come in /modules/commonjs/modulename/version/module.js or something similar. My linked module will show you the requirements and paths needed.
I use a slightly different pattern that works excellent:
First a small snippet from my "module":
Stopwatch = function(listener) {
this.totalElapsed = 0; // * elapsed number of ms in total
this.listener = (listener != undefined ? listener : null); // * function to receive onTick events
};
Stopwatch.prototype.getElapsed = function() {
return this.totalElapsed;
};
module.exports = Stopwatch;
And then this is the way I use it:
var StopWatch = require('utils/StopWatch');
var stopWatch = new StopWatch(listenerFunction);
console.log('elapsed: ' + stopWatch.getElapsed());

#load a package in F# interactive (FSharpChart.fsx)

Hi i'm a noob and asking this newbie question, please forgive me.
I've installed successfully FSharpChart in my local directory
...
Added package 'MSDN.FSharpChart.dll.0.60.0' to folder 'C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F\packages'
Added package 'MSDN.FSharpChart.dll.0.60.0' to 'packages.config'
Successfully installed 'MSDN.FSharpChart.dll 0.60.0' to Expert in F
now, if i do
#load "FSharpChart.fsx";;
^^^^^^^^^^^^^^^^^^^^^^^
stdin(4,1): error FS0078: Unable to find the file 'FSharpChart.fsx' in any of
C:\Users\Fagui\AppData\Local\Temp
additional info:
inside this folder, i see a nupkg file, and a lib directory
Inside the lib directory, there is a dll, and a pdf file,
but i don't see any .fsx file.
basically, F# has installed the package in the active folder for the current project, and F#interactive is in another folder ?? bit strange ?
should i install another time the package ? or what is the way around it ?
thanks
UPDATE:
i don't know why, but apparently when i installed the FSharpChart package, I only got the dll, no fsx file
i managed to load it doing
#I #"C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F"
#r #"packages\MSDN.FSharpChart.dll.0.60\lib\MSDN.FSharpChart.dll";;
unfortunately, typing the script in F# interactive
open MSDN.FSharp.Charting
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> FSharpChart.Point;;
doesn't yield any chart, but just returns a list
val rnd : Random
val rand : unit -> float
val randomPoints : (float * float) list =
[(9.765916457, 2.272289941); (0.8211438594, 1.625466995);
...
(7.783786034, 7.572208311); (6.497914692, 3.66987128); ...]
val it : ChartTypes.PointChart
this may be due to the fact that the library is not supported anymore, and that i should use a newer library like Thomas Petricek indicated.
So, i did manage to install FSharp.Charting instead
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> Chart.Point;;
and it did work
There is a newer version of the FSharpChart.fsx library which is called F# Charting, so first of all, I would recommend using this newer library instead (the API is quite similar, but F# Charting has a number of improvements).
The documentation for F# Charting also has a detailed page on referencing the library.
Typically, when you reference the library using NuGet, you'll need to specify relative reference:
// On Mac OSX use packages/FSharp.Charting.Gtk.0.90.13/FSharp.Charting.Gtk.fsx
#load "packages/FSharp.Charting.0.90.13/FSharp.Charting.fsx"
Where 0.90.13 is the version of the library that you got from NuGet (you may need to check the folder name - the path references in #load are relative to the place where your script lives).
Yes, F# Interactive is independent of the current project.
Use:
#load #"C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F\packages\FSharpChart.fsx";;
Also you can use the #I directive if you need to reference assemblies of a specific folder, see the reference.

qmake: How to have longer version numbers in .so file name

I'm trying to build a dynamic library on Linux using qmake. Here is my .pro file:
TEMPLATE = lib
TARGET = soTest
DEPENDPATH += .
INCLUDEPATH += .
VERSION = 3.5.2.1
The problem is that when I use qmake to make the so file I get soTest.so.3.5.2, but what I need is soTest.3.5.2.1.
How can I get qmake to use the fourth number? (build number)
Thanks.
Ok,
I figured it out. I used "VER_PAT" which allowed me to put in the last octet.
Thanks.

Resources