How to Compile When You Use PuTTY

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.

The PuTTY Windows utility allows you to remotely log in to another PC using the secure shell SSH protocol. While logged into another machine, you can make full use of the machine as long as you know how to use the command line utility, as PuTTY doesn't have a graphical interface. This might be off-putting for programmers familiar with graphical integrated development environments with a "compile" button. With PuTTY, you can even compile source code on the remote machine.

Advertisement

GCC C/C++ Compiler

Video of the Day

Step 1

Type cd into the PuTTY terminal, followed by the directory address that holds the C or C++ source code you wish to compile.

Video of the Day

Step 2

Type ls if you are using PuTTY to log into a Unix-based machine, or dir if you are using PuTTY to log into a Windows machine. This lists the files in the current directory. Ensure the source code file you wish to compile is present.

Advertisement

Step 3

Type gcc -o MyExecutable MySourceCode where "MyExecutable" is the name you want your compiled executable to bear and "MySourceCode" is the name of the source code you want to compile. It will have the C or CPP file extension, depending on whether it's a C language source file or a C++ language source file.

Advertisement

Javac Compiler

Step 1

Type cd into the PuTTY terminal, followed by the directory address that holds the Java source code you wish to compile.

Step 2

Type ls if you are using PuTTY to log in to a Unix-based machine, or dir if you are using PuTTY to log into a Windows PC. This lists the files in the current directory. Ensure the source code file you wish to compile is present.

Advertisement

Step 3

Type javac MySourceCodeFile.java where "MySourceCodeFile" is the name of the java source code file you wish to compile. The javac compiler will automatically pull in any necessary dependencies your file might need.

Advertisement

MingGW Compiler

Step 1

Type cd into the PuTTY terminal, followed by the directory address that holds the C++ source code you wish to compile.

Advertisement

Step 2

Type dir into your PuTTY terminal, because MingGW is a Windows compiler, and the terminal lists the files in your current directory. Ensure the source code file you wish to compile is present.

Step 3

Type gcc -o MyExecutable MySourceCode.cpp where "MyExecutable" is the name you want your compiled executable to bear and "MySourceCode" is the name of the source code you want to compile.

Advertisement

Advertisement

references

Report an Issue

screenshot of the current page

Screenshot loading...