How do I compile XMRig from source on Linux?
You can compile XMRig on Linux by installing its build tools, downloading the official source code, and building it with CMake. The steps below use Ubuntu or Debian and produce a native Linux program—not a miner that runs inside your web browser.
1. Install the build tools
Open a terminal on a computer you own or have permission to use. On Ubuntu, Debian, or a closely related distribution, run:
sudo apt update
sudo apt install git build-essential cmake \
libuv1-dev libssl-dev libhwloc-dev
These packages provide:
- Git: downloads the source code.
- build-essential: includes the C/C++ compiler and other build tools.
- CMake: prepares the instructions used to compile XMRig.
- Development libraries: provide networking, encryption, and information about your processor.
On Fedora, Arch, or another Linux distribution, install the equivalent packages using its package manager. The remaining build steps are broadly the same.
You need administrator access to install these packages. You do not need it for the compilation itself.
2. Download the official source
Clone the official XMRig repository, which is the project’s source-code collection:
git clone https://github.com/xmrig/xmrig.git
cd xmrig
For a more predictable build, use a published release rather than whichever development changes happen to be newest. List available version tags:
git tag --sort=-version:refname
Choose a tag that matches the release you want, then run git checkout TAG_NAME, replacing TAG_NAME with that actual tag.
Avoid source archives from advertisements, unofficial mirrors, or strangers offering “boosted” mining software. Building from source does not automatically make modified code safe.
3. Configure and compile
From inside the xmrig directory, run:
mkdir -p build
cd build
cmake ..
cmake --build . --parallel 2
CMake checks your system and prepares the build. The final command compiles XMRig using two parallel jobs.
If your computer has plenty of memory, you can speed this up by using all available processor threads:
cmake --build . --parallel "$(nproc)"
More parallel jobs use more memory. On a small virtual machine or low-memory computer, stick to one or two jobs.
Check the resulting program:
./xmrig --version
./xmrig --help
The executable is xmrig inside your build directory. You can run it there; a system-wide installation is not required.
4. Fix problems and prepare your first run
Common build failures have straightforward causes:
- Missing OpenSSL, libuv, or hwloc: check that you installed all three development packages above, then rerun
cmake ... - Compiler process “Killed”: your system may have run out of memory. Retry with
cmake --build . --parallel 1. - Errors after switching versions: create a fresh build directory and configure again.
To mine, you will also need your Monero wallet address and your mining pool’s connection details. A pool combines miners’ work and distributes payouts. You can copy the supplied configuration template into your build directory:
cp ../src/config.json ./config.json
Edit its pool settings before running ./xmrig. Never put your wallet’s recovery phrase or private keys into a miner.
Monero’s RandomX mining algorithm favors CPUs. Its fast mode needs a dataset of about 2,080 MB, plus additional working memory. Compilation succeeding does not guarantee that mining will be profitable.
The bottom line
Install the dependencies, use official XMRig source, and build without sudo. Verify the executable before configuring mining, then watch power use and temperatures during your first run.
