Skip to content

Building CUPS for OpenWrt: Bringing a Mikrotik RB2011 Printer to Life

Maks
2 minutes read

The Mikrotik RB2011UiAS-2HND-IN is a legendary device, but its native RouterOS doesn't support print servers. There's only one solution: OpenWrt. In this article, I'll explain how to build the CUPS (Common UNIX Printing System) package for this device if it's not in your build's default repository.

1. Preparing the working environment

To cross-compile, we'll need a Linux machine (I'm using Ubuntu 24.04). First, let's install a basic set of build tools:

bash
1sudo apt-get update
2sudo apt-get install build-essential libc6-dev libncurses5-dev libncursesw5-dev \
3gawk gettext git zlib1g-dev swig python3-dev command-not-found

Solving the Python 2.7 problem

Older versions of OpenWrt (19.07 and earlier) rely heavily on Python 2.7 during compilation, which has long since been deprecated in Ubuntu 24.04. Let's install it manually from the repositories of previous releases:

bash
1# Скачиваем необходимые пакеты
2wget http://security.ubuntu.com/ubuntu/pool/universe/p/python2.7/python2.7_2.7.18-13ubuntu1.5_amd64.deb \
3http://security.ubuntu.com/ubuntu/pool/universe/p/python2.7/libpython2.7-stdlib_2.7.18-13ubuntu1.5_amd64.deb \
4http://security.ubuntu.com/ubuntu/pool/universe/p/python2.7/python2.7-minimal_2.7.18-13ubuntu1.5_amd64.deb \
5http://security.ubuntu.com/ubuntu/pool/universe/p/python2.7/libpython2.7-minimal_2.7.18-13ubuntu1.5_amd64.deb
6
7# Устанавливаем одной командой
8sudo apt install ./libpython2.7-minimal_2.7.18-13ubuntu1.5_amd64.deb \
9./libpython2.7-stdlib_2.7.18-13ubuntu1.5_amd64.deb \
10./python2.7-minimal_2.7.18-13ubuntu1.5_amd64.deb \
11./python2.7_2.7.18-13ubuntu1.5_amd64.deb

2. Working with OpenWrt sources

Clone the OpenWrt repository. For RB2011, it's best to use the 19.07 branch, as it works stably on this architecture. ar71xx/ath79.


bash
1git clone -b openwrt-19.07 https://github.com/openwrt/openwrt.git openwrt-19.07
2cd openwrt-19.07

Adding CUPS to the Feeds list

By default, CUPS may not be included in your feeds. Let's add a third-party repository:


bash
1echo "src-git cups https://github.com/TheMMcOfficial/lede-cups.git" >> feeds.conf.default

3. Fixing compatibility issues

When building the old SDK on the new GCC (on Ubuntu 24.04) you will inevitably encounter a missing type error in cmake. Нужно внести правку в заголовочный файл.

Problem: Compilation error cmWorkerPool.h due to uncertainty uint64_t. Solution: Open the file (the path may differ slightly depending on the version of cmake in the SDK): nano build_dir/host/cmake-3.15.1/Source/cmWorkerPool.h

At the very beginning of the file (after the comments), add:


cpp
1#include <cstdint>

4. Configuration and assembly

Now let's update the dependencies and go to the package selection menu:

bash
1./scripts/feeds update -a
2./scripts/feeds install -a
3make menuconfig

In the menu you need to select:

  1. Target System: Atheros AR71xx/AR913x (for older kernels) or Ath79 (for new ones).
  2. Subtarget: Generic
  3. Target Profile: MikroTik RB2011UiAS-2HND
  4. Network -> Printing: Find cups and press M, to assemble it as a separate module (.ipk).

Toolchain build

This is the longest stage. We build a cross-compiler that will convert the C++ code into code understandable by the MIPS processor.

bash
1# Using all CPU cores for faster performance
2make tools/install -j$(nproc)
3make toolchain/install -j$(nproc)

The Final Push: Building the Package

Now let’s build CUPS itself, with detailed logging enabled in case of errors:

bash
1make package/cups/compile V=s

5. Result

Once the process is complete, your file .ipk will be located in the directory: bin/packages/[архитектура]/cups/

All that's left is to upload it to the router via scp and install:

bash
1opkg install cups_xxx.ipk


Important: Keep in mind that for CUPS to work on the RB2011, you will most likely need an external USB flash drive mounted as an Overlay, since the built-in memory (128 MB) may not be sufficient for logs and print queues.

Share this post