type
status
date
slug
summary
tags
category
icon
password
Because I often need to debug my home network via SSH, including the configuration of the main router, the configuration of the side router (side gateway), OpenClash, Adguard Home, MosDNS, etc., I frequently need a comfortable editor to modify
json
, yaml
, and xml
configuration files or structured data files. In my local environment, I use NeoVim more often, and I have previously shared articles about LazyVim. Currently, there is no ipk for this software in the OpenWRT system software repository, so today I will organize the process of compiling and installing NeoVim on OpenWRT and the pitfalls I encountered.📝 Main
Before You Begin Before You Begin
To avoid uncontrollable problems during the compilation and installation process, I use a brand new virtual machine environment for this tutorial. The firmware is from ImmortalWrt Firmware, Generic
x86/64
architecture, version number 23.05.3
, kernel version 5.15.162
, without any additional pre-installed software packages, consistent with the default provided software packages, and the available space is as large as possible. The actual space I used for this operation is about 1.2G, but it can be removed after the installation is completed.Also, before starting the following operations, if you are using an OpenWRT system, it is recommended to make a backup. If it is a virtual machine system, it is recommended to add a checkpoint or backup point.
Compilation and Installation Process Begins Compilation and Installation Process Begins
If you don't want to see the process, you can directly look at the summary.
First, update the software repository source through OPKG package manager.
The result returned is
Signature check passed.
and there are no errors, continue to the next step.Since we need to clone the Neovim repository on GitHub via git, we need these two software packages, where git-http is used for using git in SSL situations.
During this period, including dependencies, a total of
git, git-http, zlib, libcurl4, libnghttp2-14
software packages were installed.Clone the Neovim repository via git clone and try to execute make.
The error result returned is:
The reason is that we do not have the make software package. Install it through OPKG and try make again.
The error result returned is:
It indicates that
cmake
does not exist. OpenWrt does not provide an installation file for cmake, but we can install it indirectly through python-pip
, and the mainstream Python version is currently Python3.After trying
make
again, the error message changes:It means that the C compiler was not found. We can install
gcc
to solve this.This compilation took a long time, until an error occurred during the installation of
luajit
:We can directly install it through
opkg
.Then continue to try executing
make
, and this time the error changes:It indicates that the
ld
command does not have the ldl
option. By checking the OpenWrt documentation, it can be found that the functions in these libraries are actually directly included in the musl libc. However, since some tools try to explicitly link these libraries, you may encounter a "No Such file or directory" error. To solve this problem, just create stub libraries for them.Use Vi to create a sh file
vi run.sh
, and enter the following content in the file.Then continue to try
make CMAKE_BUILD_TYPE=RelWithDebInfo
, and this time the error content changes to:It indicates that the install command is not found. The solution to this is install the full package of install command:
The error content changes to:
It indicates that Gettext was not found. There is currently no quick installation method for Gettext packages, and we need to install it by compiling.
Then continue to try compiling neovim, and the error returned is:
We can bypass it by creating stub libraries:
At this point, the compilation is basically complete, and we can proceed with the installation.
The binary executable file is located in
/usr/local/bin
, and we can directly move it to /usr/bin
or create a soft link there. After that, if you want to install Astrovim or Lazyvim, you can directly execute it.🤗 Summary and Conclusion
OPKG Install Dependencies OPKG Install Dependencies
PIP Install Dependencies PIP Install Dependencies
Compile and Install Gettext Compile and Install Gettext
Create Stub Libraries Create Stub Libraries
Clone Neovim Repository and Compile and Install Clone Neovim Repository and Compile and Install
After completion, the
nvim
binary file is located in /usr/local/bin
.If you need the stable version of Neovim, modify CMAKE_BUILD_TYPE=Release
Directly Download Binary File Directly Download Binary File
If you do not want to compile it yourself, and you happen to have an X86_64 architecture OpenWRT, you can also directly download the binary file I compiled for use.
📎 参考文章
If you have any questions about the installation or use of OpenWrt, please feel free to leave a comment at the bottom, and let's communicate together~