the moon… beautiful! oh yeah!

Today I decided to test the Lua (the programming language, it means Moon in Portuguese) with FLTK. There is a project called lua-fltk4lua.

Unfortunately the project doesn’t explain how to compile it from source code and it expects the developer uses the “luarocks” package manager to install it.

Although initially I was getting some issues like:

No rule to make target “moon/moon.h”
No rule to make target “compat-5.3/c-api/compat-5.3.h”

I figured out how to get it compiled and working easily, find the steps below:

$ sudo apt-get install lua5.2

$ sudo apt-get install liblua5.2-dev

$ sudo apt-get install libfltk1.3-dev

$ git clone https://github.com/siffiejoe/lua-fltk4lua

$ cd lua-fltk4lua

$ git clone https://github.com/siffiejoe/lua-moon moon

$ git clone https://github.com/keplerproject/lua-compat-5.3 compat-5.3

$ make

$ sudo make install

This is a nice Hello World to see it working, just create a hello.lua file with it:

local fl = require( "fltk4lua" )
local window = fl.Window( 340, 180, "Hello" )
local box = fl.Box( 20, 40, 300, 100, "Hello World!" )
box.box = "FL_UP_BOX"
box.labelfont = "FL_HELVETICA_BOLD_ITALIC"
box.labelsize = 36
box.labeltype = "FL_SHADOW_LABEL"
window:end_group()
window:show( arg )
fl.run()

And run:

$ lua hello.lua

Just it!

7 thoughts on “the moon… beautiful! oh yeah!

  1. Thanks for posting this – BUT – a question. Was there a problem with lua 5.3? I have compiled it on my Manjaro/Arch system but it only has lua 5.3 installed.

  2. Hi Celem, the default fltk4lua is defined to use lua 5.2, you need to edit the Makefile to get it working with lua 5.3. Nothing so complicated, but using version 5.2 no modifications are needed at all.

  3. Follow-up: when I run hello.lua it fails as shown below, so obviously I need something else:
    $ lua hello.lua
    lua: error loading module ‘fltk4lua’ from file ‘./fltk4lua.so’:
    ./fltk4lua.so: undefined symbol: lua_insert
    stack traceback:
    [C]: in ?
    [C]: in function ‘require’
    hello.lua:1: in main chunk
    [C]: in ?

  4. Cool! A nice Hello World dialog box pops up. I edited the Makefile to lua5.3. I also added an uninstall. I only did the make install after carefully examining what it did, which was ok. Arch uses different locations than most other Linux systems and doing make install is frowned upon. Arch strongly recommends creating a pacman package and installing in a more controllable way. In your case with Debian, using “checkinstall” is what I always did when I used Debian-based distros. I’ve been on Manjaro/Arch for almost a year and I’m unlikely to go back – I like “rolling-releases” too much.
    Thanks again for posting.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s