Use Cygwin to compile C++ with clang, build with make, and manage code with git. Follow these steps to get started.
🔽 1. Download and Install Cygwin
- Download the Installer
Visit the Cygwin website
→ Clicksetup-x86_64.exeto download the 64-bit installer. - Run the Installer
- Double-click
setup-x86_64.exe. - Choose default options unless you have specific preferences.
- Key options:
- Installation type: Install from Internet
- Root directory: C:\cygwin64 (default)
- Local Package Directory: e.g., C:\cygwin\packages
- Download site: Choose a mirror close to your location
- Double-click
- Select Packages
On the “Select Packages” screen:- Expand the Devel category:
- ✅
clang - ✅
make
- ✅
- Expand the Utils category:
- ✅
git
- ✅
- Expand the Devel category:
- Finish Installation
- Click Next to confirm selections.
- The installer will download and install all selected packages.
- Click Finish when done.
⚙️ 2. Configure Your Environment
- Launch Cygwin
- Open Cygwin Terminal from the Start Menu or desktop shortcut.
- Verify Tools
Run the following commands to confirm installation:clang --version make --version git --version - (Optional) Add Cygwin to PATH
If commands don’t work from regular CMD/PowerShell, add Cygwin to your systemPATH:- Open: Start → System → Advanced system settings
- Click: Environment Variables
- Under System variables, edit the
Path - Add:
C:\cygwin64\bin - Click OK to save
🛠️ 3. Test Compilation and Git Setup
🔸 Create a Test C++ Program
nano hello.cpp
Paste in:
#include <iostream>
int main() {
std::cout << "Hello, Cygwin!" << std::endl;
return 0;
}
Press Ctrl+X, then Y, then Enter to save.
🔸 Compile and Run
clang++ hello.cpp -o hello ./hello
You should see:
Hello, Cygwin!
🔸 Optional: Create a Makefile
nano Makefile
Paste:
all: hello hello: hello.cpp clang++ hello.cpp -o hello clean: rm -f hello
Then run:
make # Builds the program make clean # Cleans up
🔸 Set Up Git Repository
git init git add hello.cpp Makefile git commit -m "Initial commit"
✅ Summary
You’ve now:
- ✅ Installed Cygwin with
clang,make, andgit - ✅ Compiled a C++ program
- ✅ Set up a Makefile build system
- ✅ Initialized a Git repository
You’re ready to develop and manage C++ projects in a Unix-like environment on Windows.
Let me know if you want a printable PDF version or classroom handout!
