Running the Executable
Swipe to show menu
After building your project with CMake, the compiled program is placed inside the build directory, not in your source folder. This is part of the out-of-source build approach, which keeps your project clean and organized.
# project-root/
# โโโ CMakeLists.txt
# โโโ main.c
# โโโ build/
# โโโ Makefile
# โโโ cmake_install.cmake
# โโโ CMakeFiles/
# โโโ MyApp (Linux)
# โโโ MyApp.exe (Windows)
The file named MyApp (Linux) or MyApp.exe (Windows) is your compiled program and is ready to run.
Running on Linux
To run the program on Linux, navigate to the build directory and execute it using ./:
cd build
./MyApp
Running on Windows
On Windows, open Command Prompt or PowerShell, move to the build folder, and run:
MyApp.exe
Program Output
If everything works correctly, you should see output similar to:
Hello from CMake!
Note
If your terminal says Permission denied on Linux, make the file executable:
chmod +x MyApp
Everything was clear?
Thanks for your feedback!
Sectionย 2. Chapterย 4
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Sectionย 2. Chapterย 4