Properly load lua c library (.dll)?

Discuss your Lua playlist, album art and interface scripts.
snark.real
Blank Cone
Blank Cone
Posts: 11
Joined: 13 Mar 2013 13:07
VLC version: 2.0.5 Twoflower
Operating System: Arch Linux

Properly load lua c library (.dll)?

Postby snark.real » 13 Mar 2013 13:12

Hello there! I'm trying to make use of luasocket library in my lua script by loading windows dll's with require('socket')
Plugin code is following:

Code: Select all

function descriptor() return { title = "test", version = "0.1", capabilities = { "input-listener", "playing-listener" }, } end socket = require("socket") function activate() print("activated") end function deactivate() print("deactivated") end

Directory structure in lua/extensions:

Code: Select all

. |-- plugin.lua |-- modules | |-- lua | | |-- ltn12.lua | | |-- mime.lua | | |-- socket | | | |-- ftp.lua | | | |-- http.lua | | | |-- smtp.lua | | | |-- tp.lua | | | `-- url.lua | | `-- socket.lua | |-- lua5.1.dll | |-- lua5.1.exe | |-- mime | | `-- core.dll | `-- socket | `-- core.dll
And here is the output:

Code: Select all

[02097680] lua generic debug: Activating extension 'test' [02097680] lua generic warning: Error loading script C:\Program Files (x86)\Vide oLAN\VLC\lua\extensions\plugin.lua: ...Files (x86)\VideoLAN\VLC\lua\extensions \plugin.lua:43: module 'socket' not found: no field package.preload['socket'] no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.luac' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.vle' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.luac' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.vle' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.luac' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\modules\socket.vle' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.luac' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\modules\socket.vle' no file '.\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\lua\socket\init.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\socket.lua' no file 'C:\Program Files (x86)\VideoLAN\VLC\socket\init.lua' no file 'C:\Program Files (x86)\Lua\5.1\lua\socket.luac' no file '.\socket.dll' no file 'C:\Program Files (x86)\VideoLAN\VLC\socket.dll' no file 'C:\Program Files (x86)\VideoLAN\VLC\loadall.dll' [02097680] lua generic error: Could not activate extension! [02097680] lua generic debug: Deactivating 'test' [02097680] lua generic debug: Extension thread end: 'test'
Could you please explain module loading mechanism of VLC?
What am I doing wrong? Could there be some workaround?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Properly load lua c library (.dll)?

Postby Jean-Baptiste Kempf » 13 Mar 2013 14:09

no file 'C:\Program Files (x86)\VideoLAN\VLC\socket.dll'
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

snark.real
Blank Cone
Blank Cone
Posts: 11
Joined: 13 Mar 2013 13:07
VLC version: 2.0.5 Twoflower
Operating System: Arch Linux

Re: Properly load lua c library (.dll)?

Postby snark.real » 13 Mar 2013 21:59

Oh, forgot to mention I've tried to:
* take modules/socket/core.dll
* rename it to socket.dll
* copy to 'C:\Program Files (x86)\VideoLAN\VLC\socket.dll'

Not sure if it's sane, thought :\ There is probably reason they have arranged luasocket library in such way.

And it gives me

Code: Select all

lua warning: Error loading script C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\plugin.lua: error loading module 'socket' from file 'C:\Program Files (x86)\VideoLAN\VLC\socket.dll': The specified procedure could not be found.
Could you please explain, what does it mean? Which procedure it is searching for?

Library is taken from here, by the way http://files.luaforge.net/releases/luas ... 32-vc6.zip if it's important.
I've also tried the same procedure for vs8 build from the same place (http://files.luaforge.net/releases/luas ... cket-2.0.2), with no luck.

snark.real
Blank Cone
Blank Cone
Posts: 11
Joined: 13 Mar 2013 13:07
VLC version: 2.0.5 Twoflower
Operating System: Arch Linux

Re: Properly load lua c library (.dll)?

Postby snark.real » 14 Mar 2013 00:26

Woah! I've solved my problem by placing files in following order:

Code: Select all

VideoLAN\VLC |-- mime | |-- core.dll `-- socket `-- core.dll VideoLAN\VLC\lua\extensions\ |-- plugin.lua |-- modules | |-- ltn12.lua | |-- mime.lua | |-- socket | | |-- ftp.lua | | |-- http.lua | | |-- smtp.lua | | |-- tp.lua | | `-- url.lua | `-- socket.lua
So, for all of those who wanted udp server available in lua - this is one of the solutions. Have fun :)

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Properly load lua c library (.dll)?

Postby Jean-Baptiste Kempf » 17 Mar 2013 07:45

Btw, why not exporting VLC functions?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

snark.real
Blank Cone
Blank Cone
Posts: 11
Joined: 13 Mar 2013 13:07
VLC version: 2.0.5 Twoflower
Operating System: Arch Linux

Re: Properly load lua c library (.dll)?

Postby snark.real » 17 Mar 2013 17:45

Btw, why not exporting VLC functions?
Honestly, I have tried using them, but with no luck.
Because I wanted simple "autodiscover in LAN" feature. And I got this feature done by using broadcast udp packets. As far as I know, vlc supports only tcp and tcp is only unicast.
There is only one problem to overcome left, but it's not very important anyway, and I hope to post code of my extension soon.

By the way, total size of luasocket distribution is 119.5 kB. 57.3 kB of which are dll libraries. If it's in your responsibility, please reconsider adding it to VLC distribution.
Well, if it's not possible, I can understand you.
Even if it will be some another implementation of udp in lua, something like vlc.net.listen_udp('addr', port) - that would be great too. Just remember about broadcast option ;)

Reasoning of the points above is because I think it's not nice to distribute binary libraries with lua extension. And quite plenty of people need udp.
AFAIK, if in windows, binaries in distribution is not ok, it's still acceptable.
But in linux it's not acceptable at all. If VLC is looking for libraries only in standart PATH's, you will need to 1)put them with escalated privilegies 2)possibly blow up existing system library.
And I'm not even aware of situation in MacOS.

So, that's the way the cookie crumbles :)

snark.real
Blank Cone
Blank Cone
Posts: 11
Joined: 13 Mar 2013 13:07
VLC version: 2.0.5 Twoflower
Operating System: Arch Linux

Re: Properly load lua c library (.dll)?

Postby snark.real » 26 Mar 2013 02:16

Hello again!

I've faced some strange problem in archlinux with lua51-socket-2.0.2-5 library package
When I run lua5.1 interpreter, it loads luasocket correctly:

Code: Select all

Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio > print(_VERSION) Lua 5.1 > socket = require("socket")
But when I put the same

Code: Select all

socket = require("socket")
in my plugin, VLC gives me

Code: Select all

[0x7f792c09e418] lua generic warning: Error loading script /home/snark/.local/share/vlc/lua/extensions/plugin.lua: error loading module 'socket.core' from file '/usr/lib/lua/5.1/socket/core.so': /usr/lib/lua/5.1/socket/core.so: undefined symbol: lua_gettop [0x7f792c09e418] lua generic error: Could not activate extension!
although I tested that VLC uses lua 5.1.
BTW, my VLC is version "2.0.5 Twoflower"

That's a mystery for me. Could you, pretty please explain and suggest workaround?

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Properly load lua c library (.dll)?

Postby Rémi Denis-Courmont » 17 Apr 2013 17:36

It looks to me that your core.so is not linked properly. To get the lua_gettop() symbol, it should link explicitly against liblua5.1.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 12 guests