Saturday 15 November 2014

How to configure gcc in Notepad++ for C11


Configuring notepad++ to compile and execute C programs using gcc:

Notepad++ is a free open source editor that supports several languages. It is popular for its user friendly, higher execution speed and less size. It is developed for windows environment in C++. It consumes lower memory and CPU power. It can be used to write, test and execute programs of different languages. Now we will see how notepad++ can be configured to compile and execute C programs using gcc.
Step1: Download and install the latest version of notepad++ from its official website www.notepad-plus-plus.org for free of cost
Step2: Download and install MinGw gcc as explained in the previous session.
Step3: Configure notepad++ for gcc

Creating C compiler tool in Notepad++

→ Open the notepad++
 Select Run – Run (F5)
creating tools in notepad++
→ Type the following compiler script in “The program to Run” panel
gcc -o "$(NAME_PART)" "$(FULL_CURRENT_PATH)"
gcc is to call compiler
-o is to create executable file with the file name
“$(NAME_PART)” to specify the file name without extension
“$(FULL_CURRENT_PATH)” to specify the current file and its path
For example if we save the file with “hello.c“, then the run command replaces compiler script withgcc -o hello c:\…\…\…\hello.c
Compiling tool in notepad++
 Select save to create short-cut to compiler tool (ctrl+f9)
creating compiler short-cut in notepad++

Create the C execution tool:

 Select Run – Run (F5)
 Type the C program execution script in “The program to Run” panel
"$(NAME_PART)"
Here “$(NAME_PART)” is to specify the file name without extension to call the executable file.
For example if we save the file with “hello.c” then the execution tool replaces the execution tool script with hello
 Select save to create short-cut to execution tool (ctrl+f5)
Creating C execution tool in Notepad++

Executing a C program in Notepad++:

Type the program
1
2
3
4
5
6
#include
int main()
{
  printf("Hello World");
  return 0;
}
C program in Notepad++
Use Ctrl + F9 to compile the program
Use Ctrl + F5 to execute the program
Executing a C program in Notepad++

No comments:

Post a Comment