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
4 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]