Install the following tools:
git, available onPATH.- CMake, available on
PATH: 4.2 or newer for the Visual Studio 2026 generator, or 3.21 or newer for the Visual Studio 2022 generator. - Visual Studio 2026 (VS 18) or Visual Studio 2022 (VS 17), including their Build Tools editions, with the Desktop development with C++ workload, MSVC x64/x86 tools and a Windows SDK.
- vcpkg, to install the dependencies listed in the project's
vcpkg.json.
The following commands use PowerShell. Use directories you can write to; building does not require an administrator terminal.
If vcpkg is not installed, clone and bootstrap it:
$env:VCPKG_ROOT = "$env:USERPROFILE\vcpkg"
git clone https://github.com/microsoft/vcpkg.git "$env:VCPKG_ROOT"
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat"If you already have vcpkg, set VCPKG_ROOT to that installation instead, for example:
$env:VCPKG_ROOT = "D:\vcpkg"Set VCPKG_ROOT in each new terminal session, or save it as a user environment variable.
Fetch the project source files and enter the repository root:
git clone https://github.com/stlink-org/stlink.git
cd stlinkFrom the repository root, run:
.\gen_binaries_msvc.batThe script uses vswhere, supplied by the Visual Studio Installer, to detect VS 18 with the C++ tools installed. It prefers VS 18; if none is found, it tries VS 17. It configures x64 and builds Release.
Each version uses a separate build directory so that switching versions does not conflict with a cached CMake generator:
| Visual Studio | Build directory |
|---|---|
| VS 18 (2026) | build/msvc-vcpkg-vs18 |
| VS 17 (2022) | build/msvc-vcpkg-vs17 |
During configuration, vcpkg installs libusb and pthreads from vcpkg.json into the selected build directory's vcpkg_installed subdirectory.
CMake selects PThreads4W for MSVC and links the matching Release or Debug dependency libraries. The Windows compatibility headers supply the required POSIX types.
The equivalent manual commands for VS 18 are below. For VS 17, replace the generator with Visual Studio 17 2022 and use build/msvc-vcpkg-vs17 in the commands below.
cmake -S . -B build/msvc-vcpkg-vs18 -G "Visual Studio 18 2026" -A x64 "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build build/msvc-vcpkg-vs18 --config ReleaseVisual Studio uses --config to select the build configuration. To build Debug using the same configured tree:
cmake --build build/msvc-vcpkg-vs18 --config DebugThe executables are in the selected build directory's bin/Release or bin/Debug subdirectory.
With vcpkg's default settings, the required dependency DLLs are copied beside them during the build.
For example, check the Release build with:
.\build\msvc-vcpkg-vs18\bin\Release\st-info.exe --versionIf an existing build directory was configured with a different generator, architecture or toolchain, use a new build directory for the manual commands.
NOTE:
- ST-LINK drivers are required for programmers to work with
stlink. - Package generation for MSVC is not yet implemented/tested.
Install the following packages from your package repository:
gitgccandg++orclang(C-compiler)make(Build tool)build-essential(recommended, on Debian based distros, containsgcc,g++,libc6-dev,make)cmake(Software development tool)libusb-1.0-0andlibusb-1.0-0-dev(libusb and related development headers)libgtk-4-dev>= 4.6 (optional, needed forstlink-gui)rpm(on Debian based distros, needed for package build withmake package)pandoc(optional, needed for generating manpages from markdown)
- Open a new terminal console
- Create a new destination folder at a place of your choice e.g. at
~/git:mkdir $HOME/git - Change to this directory:
cd ~/git - Fetch the project sourcefiles by running
git clone https://github.com/stlink-org/stlink.git
- Change into the project source directory:
cd stlink - Run
make clean-- required by some linux variants. - Run
make releaseto create the Release target. - Run
make installto full install the package with complete system integration. This might require sudo permissions. - Run
make debugto create the Debug target (optional)
The debug target is only necessary in order to modify the sources and to run under a debugger. - Run
make packageto build a Debian Package. The generated packages can be found in the subdirectory./build/Release/dist. - Installing system-wide (
sudo make install) requires the dynamic library cache to be updated withsudo ldconfigafterwards.
As an option you may also install to an individual user-defined folder e.g $HOME with make install DESTDIR=$HOME.
- Run
make uninstallto perform a clean uninstall of the package from the system. - Run
make cleanto clean the build-folder within the project source and remove all compiled and linked files and libraries.
Install the following packages from your package repository:
mingw-w64,autotools-devandlibtool
After following the steps for installation above, proceed with from the build dircetory itself:
$ sudo sh ./gen_binaries_win.shThe generated zip-packages can be found in the subdirectory ./build/dist.
By default most distributions don't allow access to USB devices.
In this context udev rules, which create devices nodes, are necessary to run the tools without root permissions.
To achieve this you need to ensure that the group plugdev exists and the user who is trying to access these devices is a member of this group.
Within the sourcefolder of the project, these rules are located in the subdirectory config/udev/rules.d and are automatically installed along with sudo make install on linux.
Afterwards it may be necessary to reload the udev rules:
$ sudo cp -a config/udev/rules.d/* /lib/udev/rules.d/
$ sudo udevadm control --reload-rules
$ sudo udevadm triggerudev will now create device node files, e.g. /dev/stlinkv3_XX, /dev/stlinkv2_XX, /dev/stlinkv1_XX.
As the STLINKV1's SCSI emulation is somehow broken, the best advice possibly is to tell your operating system to completely ignore it.
Choose one of the following options before connecting the device to your computer:
modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i- OR
echo "options usb-storage quirks=483:3744:i" >> /etc/modprobe.confmodprobe -r usb-storage && modprobe usb-storage
- OR
cp stlink_v1.modprobe.conf /etc/modprobe.dmodprobe -r usb-storage && modprobe usb-storage
To put the compiled shared libs into a different directory during installation,
you can use the cmake option cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" ...
The cmake build system of this toolset includes GNUInstallDirs to define GNU standard installation directories.
This module provides install directory variables as defined by the GNU Coding Standards.
Below are the preset default cmake options, which apply if none of these options are redefined:
-DCMAKE_INSTALL_SYSCONFDIR=/etc-DCMAKE_INSTALL_PREFIX=/usr/local
Please refer to the related cmake documentation for details.
Author: nightwalker-87