New to Lua, a few big surprises and still struggling to compile/run my first experiment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

New to Lua, a few big surprises and still struggling to compile/run my first experiment

Avinash D'Silva
Hi everyone,

This is my first day with Lua, I am trying to build a GUI App,
I have tried NodeJS/Electron, JavaFX and C# which allow for cross
platform GUIs, but the end package would be from anywhere near 50MB to
150MB just for a Hello World GUI program.

 I was really excited to try Lua after seeing a few talks on youtube.

When I downloaded Lua, I was like "How is this even possible".
The Lua binary was just around 230KB!!!
That's even smaller than jQuery and smaller than most GIFs on the
internet today!!

I was able to write a small Lua+FLTK GUI program in under 1 MB.
But FLTK is old & ugly(in my opinion) and I really wanted something
that looked native and modern.

This is where my problems started:

I found a portable C library: https://github.com/andlabs/libui
found another library for Lua bindings https://github.com/zhaozg/lui

libui and lua were very easy to compile because of good documentation,
even though it was my first time compiling C programs as well.

I copied the libui.a
and liblua.a from the lib folder (built using: make macosx local)

I managed to compile zhaozg/lui after porting it to Lua 5.3 and
spending my day figuring out C and it's compilation process.

The compilation succeeded and the command used is as follows on my Mac:

 gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
-fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L . -llua -lui

but now if do something like:  local ui = require "lui"

I get the following error:

lua: multiple Lua VMs detected
stack traceback:
[C]: in ?
[C]: in function 'require'

Any suggestions would be very helpful.

--
-
Warm regards,
Avinash

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Jeff Pohlmeyer
On Sat, May 5, 2018 at 5:18 PM, Avinash D'Silva
<[hidden email]> wrote:

>  gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
> -fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L . -llua -lui
...
> lua: multiple Lua VMs detected
> stack traceback:

Don't use -llua when linking lui.so (The Lua interpreter already has
lua linked in so the module doesn't need it.)

 - Jeff

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Avinash D'Silva
Jeff,

I did try that, but it ends up with a huge list of errors.

  gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
-fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L .  -lui

Undefined symbols for architecture x86_64:

  "_luaL_argerror", referenced from:

      _l_uiNewAttribute in lui-9b7f22.o

  "_luaL_checkinteger", referenced from:

      _l_uiAreaSetSize in lui-9b7f22.o

      _l_uiAreaBeginUserWindowResize in lui-9b7f22.o

      _l_uiAttributedStringInsertAtUnattributed in lui-9b7f22.o

      _l_uiAttributedStringDelete in lui-9b7f22.o

      _l_uiAttributedStringSetAttribute in lui-9b7f22.o

      _l_uiAttributedStringByteIndexToGrapheme in lui-9b7f22.o

      _l_uiAttributedStringGraphemeToByteIndex in lui-9b7f22.o

      ... and so on....


On Sat, May 5, 2018 at 11:23 PM, Jeff Pohlmeyer
<[hidden email]> wrote:

> On Sat, May 5, 2018 at 5:18 PM, Avinash D'Silva
> <[hidden email]> wrote:
>
>>  gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
>> -fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L . -llua -lui
> ...
>> lua: multiple Lua VMs detected
>> stack traceback:
>
> Don't use -llua when linking lui.so (The Lua interpreter already has
> lua linked in so the module doesn't need it.)
>
>  - Jeff
>



--
-
Warm regards,
Avinash D' Silva



☎ Mobile   | +353 892210993
✉ Gmail     | [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Avinash D'Silva
Thanks I got it working using:

gcc -o lui.so -shared -framework Foundation -framework AppKit -fPIC
-Isrc src/lui.c -I ../lua-src -I ../libui -L . -lui -undefined
dynamic_lookup

source: https://github.com/zhaozg/lui/issues/1#issuecomment-386839184


On Sat, May 5, 2018 at 11:29 PM, Avinash D'Silva
<[hidden email]> wrote:

> Jeff,
>
> I did try that, but it ends up with a huge list of errors.
>
>   gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
> -fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L .  -lui
>
> Undefined symbols for architecture x86_64:
>
>   "_luaL_argerror", referenced from:
>
>       _l_uiNewAttribute in lui-9b7f22.o
>
>   "_luaL_checkinteger", referenced from:
>
>       _l_uiAreaSetSize in lui-9b7f22.o
>
>       _l_uiAreaBeginUserWindowResize in lui-9b7f22.o
>
>       _l_uiAttributedStringInsertAtUnattributed in lui-9b7f22.o
>
>       _l_uiAttributedStringDelete in lui-9b7f22.o
>
>       _l_uiAttributedStringSetAttribute in lui-9b7f22.o
>
>       _l_uiAttributedStringByteIndexToGrapheme in lui-9b7f22.o
>
>       _l_uiAttributedStringGraphemeToByteIndex in lui-9b7f22.o
>
>       ... and so on....
>
>
> On Sat, May 5, 2018 at 11:23 PM, Jeff Pohlmeyer
> <[hidden email]> wrote:
>> On Sat, May 5, 2018 at 5:18 PM, Avinash D'Silva
>> <[hidden email]> wrote:
>>
>>>  gcc  -o lui.so  -shared  -framework Foundation -framework AppKit
>>> -fPIC -Isrc src/lui.c -I ../lua-src  -I ../libui  -L . -llua -lui
>> ...
>>> lua: multiple Lua VMs detected
>>> stack traceback:
>>
>> Don't use -llua when linking lui.so (The Lua interpreter already has
>> lua linked in so the module doesn't need it.)
>>
>>  - Jeff
>>
>
>
>
> --
> -
> Warm regards,
> Avinash D' Silva
>
>
>
> ☎ Mobile   | +353 892210993
> ✉ Gmail     | [hidden email]



--
-
Warm regards,
Avinash D' Silva



☎ Mobile   | +353 892210993
✉ Gmail     | [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Bulat Ziganshin
In reply to this post by Avinash D'Silva
Hello Avinash,

Sunday, May 6, 2018, 1:18:11 AM, you wrote:

> I was able to write a small Lua+FLTK GUI program in under 1 MB.
> But FLTK is old & ugly(in my opinion) and I really wanted something
> that looked native and modern.

I  investigated  a  lot of GUI librraies last years, looking for small,
portable, nice-looking and easy to use solution, so I can give you some
advice:

-  IUP Lua is small (500 KB to 3 MB depending on features you need) and
developed  by Lua authors themself. It has simple Lua API. It's not as
ugly  as  FLTK,  but  looks  pretty simple (similar to classic Windows
programs)

-  "Dear IMGui"  is  very small (400 KB for everything + a few
hundred KBs for Lua binding) and provides modern-looking flat view.
It's a bit limited,  though,  in particular GridView lacks some features.
Lua binding: https://github.com/patrickriordan/imgui_lua_bindings

-  for  a  more traditional choice, there are bindings to wxWindows (wxLua)
and  Qt  (lqt  and  qtlua)   - they will cost you 10-20 MB and provide
modern-looking   GUI.  You can download ZeroBraneStudio Lua IDE to see
wxLua in action and browse the IDE sources


Aside of Lua-enabled libraries, there is Sciter GUI library that provides
a  pretty  close  emulation  of html5+css3+js  in  just  5-10  MB.  It
provides   all  the  niceties of modern-looking html-based GUIs, There
are   Windows   and  Mac  versions,  while  Linux  version  ATM  is  in
alpha stage with slow development

Finally,  there  is Qt Quick which provides nice declarative language,
modern-looking (similar to html) GUIs and costs about 30 MB. It can be
halved  but  this  requires compiling library yourself. It can be even
rendered remotely in browser via WebGL backend

I personally will  choose  between  the  last  two  because  they  are
feature-complete  (unlike  ImGui),  provide  modern-looking  fluid GUI
(unlike  IUP)  and  either  support  well-known html programming model
(Sciter) or high-level declarative language (Qt Quick)


PS:   For   curiosity,  there  is  also  Red  language,  whose  whole
environment including compiler, libraries and GUI library is about 1 MB!
Unfortunately,  its GUI library is limited (no GridView at all)
and  portability  to Mac/Linux is under development. But it's the most
compact   GUI  description  language  I've  seen  -  f.e.  the  entire
calculator example is just about 5 lines of code!!!

--
Best regards,
 Bulat                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Pierre Chapuis
In addition to those, there is also Yue (https://libyue.com).

The site is pretty bland but don't let that fool you. It is basically a better Electron, written by one of its original authors.

An example application built with it (albeit with the JS bindings) is this Slack client: https://github.com/yue/wey

--
Pierre Chapuis

On Wed, May 30, 2018, at 12:01, Bulat Ziganshin wrote:

> Hello Avinash,
>
> Sunday, May 6, 2018, 1:18:11 AM, you wrote:
>
> > I was able to write a small Lua+FLTK GUI program in under 1 MB.
> > But FLTK is old & ugly(in my opinion) and I really wanted something
> > that looked native and modern.
>
> I  investigated  a  lot of GUI librraies last years, looking for small,
> portable, nice-looking and easy to use solution, so I can give you some
> advice:
>
> -  IUP Lua is small (500 KB to 3 MB depending on features you need) and
> developed  by Lua authors themself. It has simple Lua API. It's not as
> ugly  as  FLTK,  but  looks  pretty simple (similar to classic Windows
> programs)
>
> -  "Dear IMGui"  is  very small (400 KB for everything + a few
> hundred KBs for Lua binding) and provides modern-looking flat view.
> It's a bit limited,  though,  in particular GridView lacks some features.
> Lua binding: https://github.com/patrickriordan/imgui_lua_bindings
>
> -  for  a  more traditional choice, there are bindings to wxWindows (wxLua)
> and  Qt  (lqt  and  qtlua)   - they will cost you 10-20 MB and provide
> modern-looking   GUI.  You can download ZeroBraneStudio Lua IDE to see
> wxLua in action and browse the IDE sources
>
>
> Aside of Lua-enabled libraries, there is Sciter GUI library that provides
> a  pretty  close  emulation  of html5+css3+js  in  just  5-10  MB.  It
> provides   all  the  niceties of modern-looking html-based GUIs, There
> are   Windows   and  Mac  versions,  while  Linux  version  ATM  is  in
> alpha stage with slow development
>
> Finally,  there  is Qt Quick which provides nice declarative language,
> modern-looking (similar to html) GUIs and costs about 30 MB. It can be
> halved  but  this  requires compiling library yourself. It can be even
> rendered remotely in browser via WebGL backend
>
> I personally will  choose  between  the  last  two  because  they  are
> feature-complete  (unlike  ImGui),  provide  modern-looking  fluid GUI
> (unlike  IUP)  and  either  support  well-known html programming model
> (Sciter) or high-level declarative language (Qt Quick)
>
>
> PS:   For   curiosity,  there  is  also  Red  language,  whose  whole
> environment including compiler, libraries and GUI library is about 1 MB!
> Unfortunately,  its GUI library is limited (no GridView at all)
> and  portability  to Mac/Linux is under development. But it's the most
> compact   GUI  description  language  I've  seen  -  f.e.  the  entire
> calculator example is just about 5 lines of code!!!
>
> --
> Best regards,
>  Bulat                            mailto:[hidden email]
>
>

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Niccolo Medici
In reply to this post by Avinash D'Silva
On 5/6/18, Avinash D'Silva <[hidden email]> wrote:
> Hi everyone,
>
> This is my first day with Lua, I am trying to build a GUI App,
> [...]
> found another library for Lua bindings https://github.com/zhaozg/lui

Is this the same as http://tset.de/lui/index.html ?

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Gunnar Zötl

> Am 03.06.2018 um 11:46 schrieb Niccolo Medici <[hidden email]>:
>
>> found another library for Lua bindings https://github.com/zhaozg/lui
>
> Is this the same as http://tset.de/lui/index.html ?

No, it isn‘t

Gunnar

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Niccolo Medici
On 6/3/18, Gunnar Zötl <[hidden email]> wrote:

>
>> Am 03.06.2018 um 11:46 schrieb Niccolo Medici <[hidden email]>:
>>
>>> found another library for Lua bindings https://github.com/zhaozg/lui
>>
>> Is this the same as http://tset.de/lui/index.html ?
>
> No, it isn‘t
>
> Gunnar

Oh, you're the author! The man and the legend himself! :-)

Could you please write a few words explaining the difference between
zhaozg's bindings vs your bindings?

(I visited your website once and found it _very_ interesting and
useful, which is why I had it bookmarked.)

Reply | Threaded
Open this post in threaded view
|

Re: New to Lua, a few big surprises and still struggling to compile/run my first experiment

Gunnar Zötl
>>>>
>>>> found another library for Lua bindings https://github.com/zhaozg/lui
>>>
>>> Is this the same as http://tset.de/lui/index.html ?
>>
>> No, it isn‘t

> Could you please write a few words explaining the difference between
> zhaozg's bindings vs your bindings?

I can‘t comment too much on zhaog‘s binding as I‘ve just glanced over it. From the looks of it, he is doing a rather straight binding to libui, whereas I aim for a somewhat higher level, more like a gui toolkit building on libui. Also, mine has been published about 8 months before zhaong’s :)

> (I visited your website once and found it _very_ interesting and
> useful, which is why I had it bookmarked.)

thanks for the warm words :)

Gunnar