. ipk file
The. ipk file can be installed directly through OpenWrt's package management software opkg, such as the relationship between. deb file and apt. Although the official software warehouse has been very rich, sometimes it is still necessary to compile some third-party software from the source code, such as Ruijie certification
However, because the router platform is usually different from the processor architecture of commonly used servers or personal PC s, and the performance of the router processor itself is weak, it is almost impossible to compile and generate. ipk files directly on the router, so cross compilation is required
And the official OpenWrt The repository provides a convenient cross compilation environment
OpenWrt compilation preparation
Take Debian / Ubuntu as an example, refer to Requirements given on the official website , you can install dependent packages through the following command
sudo apt update sudo apt install build-essential ccache ecj fastjar file g++ gawk \ gettext git java-propose-classpath libelf-dev libncurses5-dev \ libncursesw5-dev libssl-dev python python2.7-dev python3 unzip wget \ python3-distutils python3-setuptools python3-dev rsync subversion \ swig time xsltproc zlib1g-dev
After installing / updating these dependencies, you can pull the OpenWrt repository through git
git clone https://git.openwrt.org/openwrt/openwrt.git
Usually, due to the large warehouse and network speed, it may take a long time. In fact, you can limit the depth of the pulled warehouse through -- depth, or accelerate the pull through the mirror station. Of course, you can also use both at the same time
git clone https://git.openwrt.org/openwrt/openwrt.git --depth=1 git clone https://git.openwrt.org.cnpmjs.org/openwrt/openwrt.git git clone https://git.openwrt.org.cnpmjs.org/openwrt/openwrt.git --depth=1
Compiling. ipk files
Update feeds
After entering the openwrt warehouse, you first need to update the package list feeds, which is a collection of packages that share a common location in openwrt. Run the following command to update the list of built-in packages and link to the compilation tool:
cd openwrt/ ./scripts/feeds update ./scripts/feeds install
Configuration platform
make menuconfig
The graphical menu interface is usually used to configure and compile options, and configure the processor architecture, specific processor model and equipment in turn
Take Xiaomi mini routers as an example. They should be configured as shown in the figure below
Get cross compilation chain
This step is to obtain the compilation chain required for cross compilation of the corresponding device
make tools/install V=s -j$(grep processor /proc/cpuinfo | wc -l) make toolchain/install V=s -j$(grep processor /proc/cpuinfo | wc -l)
- V=s can display all outputs in the make process, which is convenient to locate whether it is currently stuck in a step
- -j$(grep processor /proc/cpuinfo | wc -l) performs multi-threaded compilation according to the number of CPU s of the machine
Add a third-party package that needs to be compiled
You can first search whether there is a configured repository containing Makefile. With the adapted Makefile file, you can easily compile the source code and generate. ipk files
Take minieap as an example, github There are already completed warehouses on the, which can be directly pulled and compiled in turn
git clone https://github.com/BoringCat/minieap-openwrt.git package/minieap
After the warehouse is pulled, you can configure the compilation option again, and configure the functions to be compiled into. ipk into module compilation, that is, mark them as M
make menuconfig
For minieap, you can find the corresponding option in the Network and configure it as M, as shown in the following figure
After the configuration is completed, you can compile. The compilation command is also very simple. Take minieap as an example, as shown below
make package/minieap/compile V=s -j$(grep processor /proc/cpuinfo | wc -l)
After compilation, the. ipk file will be generated in the. / bin / packages / < yourarchitecture > / base directory. Copy it to the router and install it through opkg