Prerequisites
- Windows
- Linux
- FreeBSD
Install Windows SDK
Download and install the Windows SDK for your version:
Install Python 3
Download and install Python 3:
- Python 3 (check the option to add Python to PATH)
- For Windows 7, use Python 3.8.9
Install Visual Studio
Install Visual Studio 2022 or newer with:
- C++ support
- CMake tools
You can install only the Visual Studio Build Tools if you don’t want the full IDE.
Install Git Bash
Download and install Git Bash
Build and Install
Clone the repository
Clone the libmem repository with all submodules:
The
--recursive flag ensures all submodules (capstone, keystone, LIEF, etc.) are cloned.
The --depth 1 flag creates a shallow clone to save bandwidth.Generate the CMake cache
Create a build directory and generate the build files:CMake Options:
CMAKE_BUILD_TYPE=Release- Build in release mode with optimizationsCMAKE_CXX_FLAGS=-fpermissive- Allow permissive C++ compilationCMAKE_EXPORT_COMPILE_COMMANDS=1- Export compile commands for IDE support
Additional CMake Options
Additional CMake Options
You can customize the build with these options:
Build Outputs
After building, you’ll find the following files in thebuild directory:
- Windows
- Linux
- FreeBSD
libmem.dll- Dynamic link librarylibmem.lib- Import library for linkinglibmem.exp- Export file
Using the Built Library
After installation, follow the language-specific usage instructions:C/C++
Add the include directive to your source code:- GCC/Clang
- Visual Studio
- CMake
Rust
Set theLIBMEM_DIR environment variable to point to your installation:
Cargo.toml:
Python
Set theLIBDIR environment variable:
Troubleshooting
Windows
nmake is not recognized
nmake is not recognized
Make sure you’re running the command in a Visual Studio Developer Command Prompt, not a regular Command Prompt.
Python not found during build
Python not found during build
Ensure Python is in your PATH. Re-install Python and check the “Add Python to PATH” option.
Missing Windows SDK
Missing Windows SDK
Install the appropriate Windows SDK for your Windows version. CMake will report which components are missing.
Linux/FreeBSD
Permission denied during install
Permission denied during install
Make sure to run
sudo make install with root privileges.Missing kernel headers
Missing kernel headers
Install the linux-headers or kernel-devel package for your distribution.
Submodule errors
Submodule errors
If you get errors about missing submodules, run: