What Is the Main Executable in shadPS4? Build Target and Entry Point Explained
The shadPS4 project compiles into a single native binary named shadps4, defined in the top-level CMakeLists.txt via add_executable(shadps4 …), with the program entry point located in src/main.cpp.
The shadPS4 emulator is an open-source PlayStation 4 emulation project designed to run PS4 games on PC. When compiled, the project produces the main executable in shadPS4—a standalone binary called shadps4 that handles command-line input, initializes the emulator core, and boots game images. Understanding how this executable is defined and where its logic resides is essential for developers compiling from source.
How the shadps4 Executable Is Defined in CMake
The build configuration declares the executable target in the root CMakeLists.txt file using the add_executable(shadps4 …) command. This directive aggregates the complete set of source files, shaders, and linked dependencies into a single platform-specific binary. On Windows, the build produces shadps4.exe, while Linux and macOS output a binary named simply shadps4.
Source Files Behind the Main Executable
The shadps4 binary consists of two primary components: the entry point that handles initialization, and the core implementation that manages the emulation lifecycle.
Entry Point in src/main.cpp
The main function driving the emulator resides in src/main.cpp. This file handles command-line argument parsing, loads the user configuration from config.toml via src/common/config.cpp, and initializes the logging system. After setup is complete, the entry point instantiates the Core::Emulator class and invokes Core::Emulator::Run to begin execution of the loaded PS4 ELF.
Core Implementation in src/emulator.cpp
The bulk of the emulation logic lives in src/emulator.cpp and src/emulator.h, which implement the Core::Emulator class. This class initializes the virtual machine state (defined in src/core/emulator_state.h), loads the PS4 executable into memory, and manages the system lifecycle from boot to shutdown. The shadps4 binary depends on this module to translate PS4 system calls into host OS operations.
Building and Running the shadps4 Binary
To compile the main executable in shadPS4 from source, use the standard CMake workflow. The following commands clone the repository and build the shadps4 target:
# Clone and prepare build directory
git clone https://github.com/shadps4-emu/shadPS4.git
cd shadPS4
mkdir build && cd build
# Configure and build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)
Once built, run the executable from the command line with a game ID or direct path to an ELF:
# Run with a specific Game ID (e.g., CUSA00001)
./shadps4 -g CUSA00001
# Run with a direct path to an eboot.bin file
./shadps4 /path/to/eboot.bin -- --some-game-flag
# Display available command-line options
./shadps4 --help
Summary
- The main executable in shadPS4 is a native binary named
shadps4, defined by theadd_executable(shadps4 …)command inCMakeLists.txt. - The program entry point is located in
src/main.cpp, which handles CLI parsing and callsCore::Emulator::Run. - Core emulation logic resides in
src/emulator.cppwithin theCore::Emulatorclass, managing VM initialization and game execution. - The binary can be built using standard CMake commands and run directly from the terminal with game IDs or file paths.
Frequently Asked Questions
What is the name of the main executable produced by shadPS4?
The build system generates a binary named shadps4 (or shadps4.exe on Windows). This is the sole executable target defined in the project's root CMakeLists.txt file.
Where is the entry point for the shadps4 binary located?
The entry point is in src/main.cpp, which contains the standard main function. This file initializes configurations, parses command-line arguments, and launches the emulation core by calling methods from src/emulator.cpp.
How do I build the shadps4 executable from source?
Run CMake in the project root to generate build files, then compile with cmake --build .. The add_executable directive in CMakeLists.txt automatically handles linking all necessary components into the final shadps4 binary.
Can I run the shadps4 executable without using the QtLauncher GUI?
Yes. The shadps4 binary is fully functional from the command line. You can launch games directly by passing a game ID with -g or a path to an ELF file, making it unnecessary to use the QtLauncher GUI for basic operation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →