Programming has come a long way from its early Assembly days. Now we have a lot of different programming languages to choose from, each with its difficulties and pros and cons.
However, that’s not to say you’ll get through writing code without hitting any snags. In this article, we’re talking about the “clang: error: no input files” issue that you might face with C++ and how to fix the problem.
Run the xcode installer
The first thing you should do is run the xcode-select installer. It’ll download and set up any file you might need to run clang. Run the following command in the terminal, and you’re good to go.
xcode-select -- install
Check the file directory
Before you can run your script, your terminal needs to be in the same directory as your script itself. You can either navigate to the folder, right-click and open a terminal, or use the cd command to navigate the folder tree inside the terminal.
Regardless, once you’re in the same directory as the script, try running it, and it should work just fine, provided there were no other bugs in the code.
Point to xcode
Sometimes your computer might not know where Xcode is installed even after installing the package. In such cases, you can manually point to your Xcode installation using the following command.
sudo xcode-select --switch /Applications/Xcode.app
Specify the GCC version
Sometimes the compiler might be unable to find a file to compile using GCC. In such cases, you will have to specify the GCC version installed on your machine manually. To find the GCC version, run the following command in the terminal.