How to Install LuaJIT library on Ubuntu/Debian Linux


In this article, we will see how to install LuaJIT library on Ubuntu/Debian Linux. LuaJIT is a Just-in-Time(JIT) compiler for Lua programming language. It has been very frequently used as a scripting middleware in games, appliances, network and graphics apps, numerical simulations, trading platforms and many other specialty applications. It is so widely used that many times people would be using without knowing about it. LuaJIT is a key component of millions of web sites, huge SaaS installations, network switches, set-top boxes and other embedded devices. It is also quite easy to install and use on almost all the famous platforms. Here we will see the steps to install LuaJIT library on Ubuntu/Debian Linux systems.


How to Install LuaJIT library on Ubuntu/Debian Linux

How to Install LuaJIT library on Ubuntu/Debian Linux

Also Read: Solved "ERROR! flex not found" on Ubuntu/Debian Linux

Step 1: Prerequisites

a) You should have a running Ubuntu/Debian Linux Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get package manager available in your Server.

d) You should have git utility available in your Server.


Step 2: Update Your Server

Before installing LuaJIT library, it is highly recommended to first check all the latest available updates and then install them by running sudo apt update && sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Hit:1 focal InRelease
Hit:2 focal InRelease
Hit:3 stable InRelease
Hit:4 focal InRelease
Get:5 focal-security InRelease [114 kB]
Hit:6 focal InRelease
Hit:7 focal InRelease
Get:8 focal-updates InRelease [114 kB]
Hit:9 apt/stable/ InRelease
Hit:10 focal InRelease
Hit:11 buster InRelease
Hit:12 focal InRelease
Hit:13 pgadmin4 InRelease
Hit:14 focal InRelease
Get:15 focal-backports InRelease [108 kB]
Hit:16 focal InRelease


Step 3: Install LuaJIT library

There are basically two ways to install LuaJIT library. You can use any of the below method depending on your requirements and needs.

a) Using Source Code

The official and recommended way to install LuaJIT library is through the source code. For that, you need to first clone the code from official download page using git command as shown below.

cyberithub@ubuntu:~$ git clone
Cloning into 'luajit'...

Then switch to directory by using cd luajit command as shown below.

cyberithub@ubuntu:~$ cd luajit

Finally, compile and install the library by running make && sudo make install command as shown below.

cyberithub@ubuntu:~/luajit$ make && sudo make install
==== Building LuaJIT 2.1 ====
make -C src
make[1]: Entering directory '/home/cyberithub/luajit/src'
HOSTCC host/minilua.o
HOSTLINK host/minilua
VERSION luajit.h
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
HOSTLINK host/buildvm
ASM lj_vm.o
CC lj_assert.o
CC lj_gc.o
BUILDVM lj_ffdef.h
CC lj_err.o
CC lj_char.o
BUILDVM lj_bcdef.h
CC lj_bc.o
CC lj_obj.o
CC lj_buf.o
CC lj_str.o
CC lj_tab.o
CC lj_func.o
CC lj_udata.o
CC lj_meta.o
CC lj_debug.o
CC lj_prng.o
CC lj_state.o
CC lj_dispatch.o
CC lj_vmevent.o
CC lj_vmmath.o
CC lj_strscan.o
CC lj_strfmt.o
CC lj_strfmt_num.o
CC lj_serialize.o
CC lj_api.o
CC lj_profile.o
CC lj_lex.o
CC lj_parse.o
CC lj_bcread.o
CC lj_bcwrite.o
CC lj_load.o
CC lj_ir.o
CC lj_opt_mem.o
BUILDVM lj_folddef.h
CC lj_opt_fold.o
CC lj_opt_narrow.o
CC lj_opt_dce.o
CC lj_opt_loop.o
CC lj_opt_split.o
CC lj_opt_sink.o
CC lj_mcode.o
CC lj_snap.o
CC lj_record.o
CC lj_crecord.o
BUILDVM lj_recdef.h
CC lj_ffrecord.o
CC lj_asm.o
CC lj_trace.o
CC lj_gdbjit.o
CC lj_ctype.o
CC lj_cdata.o
CC lj_cconv.o
CC lj_ccall.o
CC lj_ccallback.o
CC lj_carith.o
CC lj_clib.o
CC lj_cparse.o
CC lj_lib.o
CC lj_alloc.o
CC lib_aux.o
BUILDVM lj_libdef.h
CC lib_base.o
CC lib_math.o
CC lib_bit.o
CC lib_string.o
CC lib_table.o
CC lib_io.o
CC lib_os.o
CC lib_package.o
CC lib_debug.o
CC lib_jit.o
CC lib_ffi.o
CC lib_buffer.o
CC lib_init.o
AR libluajit.a
CC luajit.o
BUILDVM jit/vmdef.lua
LINK luajit
OK Successfully built LuaJIT
make[1]: Leaving directory '/home/cyberithub/luajit/src'
==== Successfully built LuaJIT 2.1 ====
==== Installing LuaJIT 2.1.1693350652 to /usr/local ====
mkdir -p /usr/local/bin /usr/local/lib /usr/local/include/luajit-2.1 /usr/local/share/man/man1 /usr/local/lib/pkgconfig /usr/local/share/luajit-2.1/jit /usr/local/share/lua/5.1 /usr/local/lib/lua/5.1
cd src && install -m 0755 luajit /usr/local/bin/luajit-2.1.1693350652
cd src && test -f libluajit.a && install -m 0644 libluajit.a /usr/local/lib/libluajit-5.1.a || :
rm -f /usr/local/lib/ /usr/local/lib/ /usr/local/lib/
cd src && test -f && \
install -m 0755 /usr/local/lib/ && \
( ldconfig -n 2>/dev/null /usr/local/lib || : ) && \
ln -sf /usr/local/lib/ && \
ln -sf /usr/local/lib/ || :
cd etc && install -m 0644 luajit.1 /usr/local/share/man/man1
cd etc && sed -e "s|^prefix=.*|prefix=/usr/local|" -e "s|^multilib=.*|multilib=lib|" -e "s|^relver=.*|relver=1693350652|" luajit.pc > luajit.pc.tmp && \
install -m 0644 luajit.pc.tmp /usr/local/lib/pkgconfig/luajit.pc && \
rm -f luajit.pc.tmp
cd src && install -m 0644 lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h /usr/local/include/luajit-2.1
cd src/jit && install -m 0644 bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua dis_arm64be.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua dis_mips64.lua dis_mips64el.lua dis_mips64r6.lua dis_mips64r6el.lua vmdef.lua /usr/local/share/luajit-2.1/jit
ln -sf luajit-2.1.1693350652 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.1.1693350652 to /usr/local ====

b) Using APT

Second method which is usually not the preferred one is by installing through apt package manager from default Ubuntu repo. You can only use this method if you are looking for older version or unable to install through source code. In this method, you can install LuaJIT package by running sudo apt install luajit command as shown below. This will download and install the package along with all its dependencies from default Ubuntu repo.

cyberithub@ubuntu:~$ sudo apt install luajit
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 231 kB of archives.
After this operation, 530 kB of additional disk space will be used.
Get:1 focal/universe amd64 luajit amd64 2.1.0~beta3+dfsg-5.1build1 [231 kB]
Fetched 231 kB in 1s (154 kB/s)
Selecting previously unselected package luajit.
(Reading database ... 258704 files and directories currently installed.)
Preparing to unpack .../luajit_2.1.0~beta3+dfsg-5.1build1_amd64.deb ...
Unpacking luajit (2.1.0~beta3+dfsg-5.1build1) ...
Setting up luajit (2.1.0~beta3+dfsg-5.1build1) ...
Processing triggers for man-db (2.9.1-1) ...


Step 4: Verify Installation

If you installed the LuaJIT library package through APT package manager then you can verify the installed files path by using dpkg -L luajit command as shown below.

cyberithub@ubuntu:~$ dpkg -L luajit


Step 5: Check Version

You can also verify the current installed LuaJIT version by using luajit -v command as shown below.

cyberithub@ubuntu:~$ luajit -v
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall.

Leave a Comment