Skip to content

Instantly share code, notes, and snippets.

@btbytes
Created June 10, 2020 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btbytes/71ec02338daee2d394135bc96862b268 to your computer and use it in GitHub Desktop.
Save btbytes/71ec02338daee2d394135bc96862b268 to your computer and use it in GitHub Desktop.
Compiling a Lua + FLTK Application binary application on Mac.

fltk4lua:

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

Make some changes to Makefile to fit my mac os's setup:

diff --git a/Makefile b/Makefile
index 7a0a862..7d3b91b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,14 @@
 .SUFFIXES: .cxx

 # works for Lua 5.2 on Debian based Linuxes:
-DLL_INSTALL_DIR = /usr/lib/lua/5.2
-LUA_INCDIR = /usr/include/lua5.2
+DLL_INSTALL_DIR = /usr/local/lib/lua/5.3/
+LUA_INCDIR = /usr/local/Cellar/lua/5.3.5_1/include/lua
 FLTK_CONFIG = fltk-config
 AR = ar
 RANLIB = ranlib
-CC = gcc
+CC = clang
 CFLAGS = -Wall -Wextra -fpic -Os
-MYCFLAGS = ${CFLAGS} -I${LUA_INCDIR} -Imoon -Icompat-5.3/c-api \
+MYCFLAGS = ${CFLAGS} -I${LUA_INCDIR} -llua -Imoon -Icompat-5.3/c-api \
            -DMOON_PREFIX=f4lx -DCOMPAT53_PREFIX=f4lx -DNDEBUG \
            `${FLTK_CONFIG} --use-images --cxxflags`
 MYLDFLAGS = `${FLTK_CONFIG} --use-images --ldflags` -lstdc++

Make and install

make
make install

Run the example:

cd examples
lua hello.lua # you should see the hello window.

Install luastatic using luarocks:

luarocks install luastatic

Build the mac binary:

luastatic hello.lua /usr/local/Cellar/lua/5.3.5_1/lib/liblua.5.3.dylib -I/usr/local/Cellar/lua/5.3.5_1/include/lua/

Run the newly created hello binary: ./hello.

You should see the hello application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment