Cyberithub

How to Install LuaJIT library on Ubuntu/Debian Linux

Advertisements

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

Advertisements

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.

Advertisements

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

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

Advertisements

 

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 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:4 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:6 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:7 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:9 https://download.sublimetext.com apt/stable/ InRelease
Hit:10 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:11 https://ngrok-agent.s3.amazonaws.com buster InRelease
Hit:12 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:13 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
Hit:14 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Get:15 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:16 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu 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.

Advertisements

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 https://luajit.org/git/luajit.git
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
BUILDVM lj_vm.S
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
DYNLINK libluajit.so
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/libluajit-5.1.so.2.1.1693350652 /usr/local/lib/libluajit-5.1.so /usr/local/lib/libluajit-5.1.so.2
cd src && test -f libluajit.so && \
install -m 0755 libluajit.so /usr/local/lib/libluajit-5.1.so.2.1.1693350652 && \
( ldconfig -n 2>/dev/null /usr/local/lib || : ) && \
ln -sf libluajit-5.1.so.2.1.1693350652 /usr/local/lib/libluajit-5.1.so && \
ln -sf libluajit-5.1.so.2.1.1693350652 /usr/local/lib/libluajit-5.1.so.2 || :
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:
luajit
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 http://in.archive.ubuntu.com/ubuntu 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
/.
/usr
/usr/bin
/usr/bin/luajit
/usr/share
/usr/share/doc
/usr/share/doc/luajit
/usr/share/doc/luajit/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/luajit.1.gz
/usr/share/doc/luajit/changelog.Debian.gz

 

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. http://luajit.org/

Leave a Comment