A simple yet powerful Windows batch script that allows you to compile and run C++ files with a single command. This script streamlines the C++ development workflow by eliminating the need to type lengthy compile and execute commands repeatedly.
- Single command compilation and execution of C++ files
- Universal compatibility with any C++ source file
- Simplified workflow for C++ development
- Command available system-wide once configured
- Windows Operating System
- g++ compiler (part of the GCC suite)
- Can be installed through MinGW or MSYS2 if not already present
- Download the
runcpp.batscript - Place it in your preferred scripts directory (e.g.,
C:\Users\<YourName>\cppscript)
Add the script's directory to your system's PATH to make it accessible from anywhere:
-
Open Environment Variables:
- Press
Win + R - Type
sysdm.cpland press Enter - Navigate to the Advanced tab
- Click Environment Variables
- Press
-
Edit PATH:
- Under User variables, select
Path - Click Edit
- Click New
- Add the full path to your scripts folder (e.g.,
C:\Users\<YourName>\cppscript) - Click OK to save changes
- Under User variables, select
- Close and reopen any command prompt or PowerShell windows for changes to take effect
Once installed, you can use the script with any C++ file using the following syntax:
runcpp <filename.cpp>runcpp mock.cppThis command will:
- Compile your C++ file using g++
- Execute the resulting program automatically
-
"'runcpp' is not recognized as an internal or external command"
- Verify that the script's directory is correctly added to PATH
- Ensure you've restarted your terminal after PATH modifications
-
"'g++' is not recognized as an internal or external command"
- Confirm that g++ is properly installed
- Check if g++ is available in your system's PATH
- Consider reinstalling MinGW or MSYS2 if needed
Contributions are welcome! If you have suggestions for improvements or bug fixes:
- Fork the repository
- Create your feature branch
- Commit your changes
- Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- GCC team for the g++ compiler
- Windows batch scripting community
If you encounter any issues or need assistance:
- Check the troubleshooting section above
- Open an issue in the repository
- Contact the maintainer
Note: This script is designed for Windows environments only. For Linux/Mac users, consider creating an equivalent shell script suited for your operating system.