[Freeswitch-users] Latest FreeSWITCH pull and Lua

James Mortensen james.mortensen at synclio.com
Fri Dec 13 02:51:45 MSK 2013


Here's what I've since discovered:

- Verified FreeSWITCH uses Lua 5.2.2 -
see freeswitch/src/mod/languages/mod_lua/lua/lua.h
- Manually built and compiled the same Lua 5.2.2 for the system Lua
- Downloaded and compiled from source the latest LibXml using the Lua 5.2.2
development headers.

gcc -shared -fPIC -Wl,-E -o LuaXML_lib.so LuaXML_lib.c
-I/mnt/src/lua/lua-5.2.2/src

- Copied the .so binary to /usr/local/lib/lua/5.2/LuaXML_lib.so.


Afterwards, verify the system Lua can load the library:

test.lua:
  print('hello world from lua')
require('LuaXML')
print(_VERSION)
print("---\nREADY.")

ubuntu at fs#  lua /mnt/scripts/test.lua
hello world from lua
Lua 5.2
---
READY.


The library loads without incident.  But, when we try to run the same test
script from the CLI, we get the following:

freeswitch at ip-10-166-245-111> lua test.lua
hello world from lua
2013-12-12 23:21:08.515046 [ERR] mod_lua.cpp:199 error loading module
'LuaXML_lib' from file '/usr/local/lib/lua/5.2/LuaXML_lib.so':
 /usr/local/lib/lua/5.2/LuaXML_lib.so: undefined symbol: lua_gettop
stack traceback:
[C]: in ?
 [C]: in function 'require'
/usr/local/share/lua/5.2/LuaXML.lua:1: in main chunk
[C]: in function 'require'
 /opt/freeswitch-1.5.8-2013-12-11/scripts/test.lua:2: in main chunk

-ERR Cannot execute script

freeswitch at ip-10-166-245-111>



Now, I'm not sure what the issue is, but if the library compiles and even
runs with the same Lua version that's embedded in FreeSWITCH, why would it
not work when called from within FreeSWITCH?



James


On Thu, Dec 12, 2013 at 12:02 AM, James Mortensen <
james.mortensen at synclio.com> wrote:

> Okay, so I figured out that the multiple Lua VMs detected is because the
> version of Lua was slightly different than the compiled .so file for
> LuaXML_lib, even though it said it was the right version. So I recompiled
> it and added it into the /usr/local/lib/lua/5.2 folder, and I put
> LuaXml.lua into /usr/local/share/lua/5.2.
>
> Now, I'm seeing these undefined symbol errors and will need to tackle this
> next:
>
> 2013-12-12 07:41:53.395054 [ERR] mod_lua.cpp:199 error loading module
> 'LuaXML_lib' from file '/usr/local/lib/lua/5.2/LuaXML_lib.so':
>  /usr/local/lib/lua/5.2/LuaXML_lib.so: undefined symbol: lua_gettop
> stack traceback:
> [C]: in ?
>  [C]: in function 'require'
> /usr/local/share/lua/5.2/LuaXml.lua:1: in main chunk
> [C]: in function 'require'
>  /opt/freeswitch/scripts/parser.lua:2: in main chunk
>
>
>
>
>
> James
>
>
>
> On Wed, Dec 11, 2013 at 6:26 PM, James Mortensen <
> james.mortensen at synclio.com> wrote:
>
>> Just to update this thread, I created the following Lua script:
>>
>>  print('hello world from lua')^M
>> print(_VERSION)
>> print("---\nREADY.")
>>
>> and then ran it from the CLI.  The output was:
>>
>> freeswitch at fs> lua test.lua
>> hello world from lua
>> Lua 5.2
>> ---
>> READY.
>>
>>  Also, I found part of the answer to my problem. FreeSWITCH Lua was
>> updated to 5.2 on Nov 12th, 2771498707c194c70cf25ad9473be66ef59cfb46, so I
>> went ahead and grabbed the corresponding LuaXml library for version 5.2 not
>> 5.1.
>>
>>
>> 2013-12-12 02:12:42.615049 [ERR] mod_lua.cpp:199 multiple Lua VMs detected
>> stack traceback:
>> [C]: in ?
>>  [C]: in function 'require'
>> /usr/local/share/lua/5.2/LuaXml.lua:1: in main chunk
>> [C]: in function 'require'
>>  /opt/freeswitch/scripts/parser.lua:2: in main chunk
>>
>> So now it's a matter of tracing down this error, which is where this
>> mailing list post left off:
>> http://freeswitch-users.2379917.n2.nabble.com/Not-really-a-Freeswitch-issue-but-td7595250.html
>>
>> I'll keep pounding away at this and update the list once I figure it out.
>>
>>
>> James
>>
>>
>> On Wed, Dec 11, 2013 at 4:05 PM, James Mortensen <
>> james.mortensen at synclio.com> wrote:
>>
>>> Hello,
>>>
>>> I just ran git pull and rebuilt FreeSWITCH, and now Lua is unable to
>>> locate the LuaXml library.
>>>
>>> module 'LuaXml' not found:
>>> no field package.preload['LuaXml']
>>>  no file '/usr/local/lib/lua/5.2/LuaXml.so'
>>> no file '/usr/local/lib/lua/5.2/loadall.so'
>>>  no file './LuaXml.so'
>>>
>>> and another:
>>>
>>> module 'LuaXml' not found:
>>> no field package.preload['LuaXml']
>>>  no file './LuaXml.so'
>>> no file '/usr/local/lib/lua/5.1/LuaXml.so'
>>> no file '/usr/lib/x86_64-linux-gnu/lua/5.1/LuaXml.so'
>>>  no file '/usr/lib/lua/5.1/LuaXml.so'
>>> no file '/usr/local/lib/lua/5.1/loadall.so'
>>>
>>> Note that in /usr/local/lib/lua/5.1 there is a LuaXML_lib.so, but no
>>> LuaXml.so.
>>>
>>> Those are example of one of the many error messages the system has been
>>> spitting out at me.  Tt's complaining about not finding a LuaXml.so despite
>>> none actually existing on the box and despite following the instructions in
>>> the wiki.
>>>
>>> I already followed the instructions in
>>> http://wiki.freeswitch.org/wiki/Mod_lua for installing LuaXml via the
>>> luarocks package manager, so since that didn't work I tried including the
>>> library manually from the luaxml website.  Although the lua on the box can
>>> run the test.lua script successfully, I am not having luck in FreeSWITCH.
>>>
>>> I also tried recompiling from scratch running the bootstrap and
>>> configure scripts.  No luck.
>>>
>>> I've also tried installing both Lua 5.1 and Lua 5.2.  I realize the wiki
>>> shows 5.1 being used, but I already tried that and moved onto trying other
>>> things.  Still working on trying to figure out what happened, but wanted to
>>> see if anyone else is having any trouble with this as well.  I realize Lua
>>> is embedded in FreeSWITCH, so I'm a bit confused about why it can't find
>>> the library.
>>>
>>> Using lua 5.2 on the box, I can run the test.lua script that users the
>>> library, what version of Lua does FreeSWITCH use?  I'm not convinced it's
>>> using an embedded version of Lua based on the fact that I see it trying to
>>> use the paths from the Lua installed from apt-get.
>>>
>>>
>>> James
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20131212/eb9ed9b5/attachment-0001.html 


Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list