In this article, we will see how to solve "Can't Find luajit" or No package 'luajit' found error. Many times you might have noticed that whenever you try to install an application through source code, during configuration check the installation fails with "Can't Find luajit" or No package 'luajit' found error. Something similar happened to me as well when I tried installing Snort 3 on my Ubuntu 22.04 LTS system. While running ./configure_cmake.sh
script, it failed with error "Can't Find luajit" or No package 'luajit' found.
After checking this error for a while, I understood the root cause of the problem. So thought to write an article about this so that it will help you folks as well. If you are also facing the same issue then I would suggest you to go through below mentioned solution steps to fix the error and proceed with the installation.
[Solved]: "Can't Find luajit" or No package 'luajit' found
Also Read: How to Install Snort on Ubuntu 22.04
As mentioned, when i was trying to configure snort 3
source code for installation then while running ./configure_cmake.sh
script, i noticed "Can't Find luajit" found
error on the output as shown below.
cyberithub@ubuntu:~/snort3-3.1.71.0$ ./configure_cmake.sh ./configure_cmake.sh: 486: [: Illegal number: Build Directory : build Source Directory: /home/cyberithub/snort3-3.1.71.0 -- The CXX compiler identification is Clang 14.0.0 -- The C compiler identification is GNU 11.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Checking for module 'libdaq>=3.0.12' -- Found libdaq, version 3.0.12 -- Found DAQ: /usr/local/lib/libdaq.so -- Checking for module 'libdaq_static_afpacket' -- Found libdaq_static_afpacket, version 3.0.12 -- Checking for module 'libdaq_static_fst' -- Found libdaq_static_fst, version 3.0.12 -- Checking for module 'libdaq_static_gwlb' -- Found libdaq_static_gwlb, version 3.0.12 -- Checking for module 'libdaq_static_savefile' -- Found libdaq_static_savefile, version 3.0.12 -- Checking for module 'libdaq_static_trace' -- Found libdaq_static_trace, version 3.0.12 -- Found DNET: /usr/include -- Found FLEX: /usr/bin/flex (found suitable version "2.6.4", minimum required is "2.6.0") -- Checking for module 'hwloc' -- Found hwloc, version 2.7.0 -- Found HWLOC: /usr/lib/x86_64-linux-gnu/libhwloc.so -- Checking for module 'luajit' -- No package 'luajit' found CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Can't Find luajit! Get it from http://luajit.org/download.html or use the --with-luajit-* options if you have it installed inn an unusual place. (missing: LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR) Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) cmake/FindLuaJIT.cmake:44 (find_package_handle_standard_args) cmake/include_libraries.cmake:8 (find_package) CMakeLists.txt:27 (include) -- Configuring incomplete, errors occurred! See also "/home/cyberithub/snort3-3.1.71.0/build/CMakeFiles/CMakeOutput.log".
While above error could occur due to multiple reasons but most of the time it occurs due to missing LuaJIT library
in the system. So to fix the problem, you have to install the library from latest available source code. First clone the repo from GitHub using git clone https://luajit.org/git/luajit.git
command as shown below.
cyberithub@ubuntu:~$ git clone https://luajit.org/git/luajit.git Cloning into 'luajit'... Fetching objects: 19422, done.
Switch to the directory by using cd luajit
command as shown below.
cyberithub@ubuntu:~$ cd luajit
Then compile and install the package 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.1695653777 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.1695653777 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.1695653777 /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.1695653777 && \ ( ldconfig -n 2>/dev/null /usr/local/lib || : ) && \ ln -sf libluajit-5.1.so.2.1.1695653777 /usr/local/lib/libluajit-5.1.so && \ ln -sf libluajit-5.1.so.2.1.1695653777 /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=1695653777|" 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.1695653777 /usr/local/bin/luajit ==== Successfully installed LuaJIT 2.1.1695653777 to /usr/local ====
Now if you run the ./configure_cmake.sh
script again and check, you will notice that the library is getting detected as shown below.
cyberithub@ubuntu:~/snort3-3.1.71.0$ ./configure_cmake.sh ./configure_cmake.sh: 486: [: Illegal number: Build Directory : build Source Directory: /home/cyberithub/snort3-3.1.71.0 -- The CXX compiler identification is Clang 14.0.0 -- The C compiler identification is GNU 11.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Checking for module 'libdaq>=3.0.12' -- Found libdaq, version 3.0.12 -- Found DAQ: /usr/local/lib/libdaq.so -- Checking for module 'libdaq_static_afpacket' -- Found libdaq_static_afpacket, version 3.0.12 -- Checking for module 'libdaq_static_fst' -- Found libdaq_static_fst, version 3.0.12 -- Checking for module 'libdaq_static_gwlb' -- Found libdaq_static_gwlb, version 3.0.12 -- Checking for module 'libdaq_static_savefile' -- Found libdaq_static_savefile, version 3.0.12 -- Checking for module 'libdaq_static_trace' -- Found libdaq_static_trace, version 3.0.12 -- Found DNET: /usr/include -- Found FLEX: /usr/bin/flex (found suitable version "2.6.4", minimum required is "2.6.0") -- Checking for module 'hwloc' -- Found hwloc, version 2.7.0 -- Found HWLOC: /usr/lib/x86_64-linux-gnu/libhwloc.so -- Checking for module 'luajit' -- Found luajit, version 2.1.1695653777 -- Found LuaJIT: /usr/local/lib/libluajit-5.1.so (found version "2.1.1695653777")