https://github.com/yuvrajkarna2717/cpp_setup
A setup designed to help write code faster during programming contests.
https://github.com/yuvrajkarna2717/cpp_setup
competitive-programming-contests cpp
Last synced: 11 months ago
JSON representation
A setup designed to help write code faster during programming contests.
- Host: GitHub
- URL: https://github.com/yuvrajkarna2717/cpp_setup
- Owner: yuvrajkarna2717
- Created: 2025-07-31T10:46:02.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-08-11T10:02:26.000Z (11 months ago)
- Last Synced: 2025-08-11T12:08:21.869Z (11 months ago)
- Topics: competitive-programming-contests, cpp
- Language: C++
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## π» Requirements
Before you begin, ensure you have the following tools installed:
### πΉ For Windows (using MSYS2 - Recommended)
1. Download & install [**MSYS2**](https://www.msys2.org/)
2. Launch the **MSYS2 MinGW 64-bit** shell
3. Run the following commands:
```bash
pacman -Syu # Update MSYS2 packages (restart if needed)
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake
````
This installs:
* `g++` compiler
* `make`
* `cmake`
> β οΈ Make sure you're using the `MINGW64` shell (`mingw64.exe`), **not** the `MSYS` or `UCRT` ones.
## π Setup & Build Instructions (Highly Detailed)
These steps will guide you from cloning the repo to compiling and running your project on any machine.
### β
Step 1: Clone the Repository
```bash
git clone https://github.com/yuvrajkarna2717/cpp_setup.git
cd cpp_setup
```
### β
Step 2: Create the Build Directory
CMake prefers out-of-source builds (keeps things clean):
```bash
mkdir build
cd build
```
### β
Step 3: Run CMake to Generate Build Files
```bash
cmake ..
```
* This scans `CMakeLists.txt`, checks for your compiler, and prepares a build system.
* It will fail if `cmake` or `g++` are not installed.
### β
Step 4: Build the Project
```bash
cmake --build .
```
* Compiles `main.cpp` into an executable (e.g., `main.exe` on Windows)
* Incremental: Only recompiles changed files.
### β
Step 5: Run the Executable
```bash
./main.exe # Windows
./main # macOS/Linux
```
---
## π Quick Rebuild & Run Using `run.sh`
Instead of running commands manually every time, you can use the helper script:
### π `run.sh` Contents
```bash
#!/bin/bash
cd build || exit
cmake --build .
echo -e "\n--- Running ---\n"
./main.exe
```
### βΆοΈ How to Use It
1. Make it executable (only once):
```bash
chmod +x run.sh
```
2. Run the full compile + execute process:
```bash
./run.sh
```
> π This script assumes you already have a `build/` directory and itβs configured via `cmake ..`. If not, run steps 2 & 3 first.
---
## π What to Do After Code Changes?
| Change Type | What You Run |
| ------------------------ | --------------------------------------------- |
| `.cpp` or `.h` modified | `cmake --build . && ./main.exe` or `./run.sh` |
| New file / renamed file | `cmake .. && cmake --build . && ./main.exe` |
| `CMakeLists.txt` changed | `cmake ..` again before building |
---
## π Project Structure
```
cpp_setup/
βββ CMakeLists.txt # CMake configuration
βββ main.cpp # Entry point
βββ run.sh # Automate build + run
βββ build/ # (Generated) build files & executable
```
---
## π License
MIT License β free to use, modify, and distribute.
---
## π¨βπ» Author
[Yuvraj Karna](https://github.com/yuvrajkarna2717)
---
## π Support
If this project helps you, please consider β starring the repo to show your support!