Tutorial — primer-programa
Learn by programming: follow each step, write your own code, then apply it to the course assignment.
What you will build
A CMake console executable that prints a greeting.
-
1 Create the project folder
Create `hola-cpp/` with `CMakeLists.txt` and `main.cpp`. Open the folder in VS Code or your preferred IDE.Tip: Environment: /en/introduccion/entorno/
-
2 Configure CMake
Run `cmake -B build` from the root. CMake generates build files inside `build/`.cmake_minimum_required(VERSION 3.16) project(hola_cpp CXX) add_executable(hola main.cpp) -
3 Write main.cpp
Print a greeting. This is the same skeleton you will use in class and assignments.#include <iostream> int main() { std::cout << "Hola, Computacion II!" << std::endl; return 0; } -
4 Build and run
Run `cmake --build build` then `./build/hola` (path may vary). You should see the message in the terminal.