Running the Executable
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!
If your terminal says Permission denied on Linux, make the file executable:
chmod +x MyApp
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Can you explain what an out-of-source build is?
What should I do if I don't see the compiled program in the build directory?
How do I clean or rebuild my project with CMake?
Awesome!
Completion rate improved to 6.67
Running the Executable
Desliza para mostrar el menú
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!
If your terminal says Permission denied on Linux, make the file executable:
chmod +x MyApp
¡Gracias por tus comentarios!