how to install and run the simple code on MinGW through GCC for Pthread coding

Prerequisite: MinGW need to installed

Install GCC on MinGW : pacman -Syu gcc

After successful installation you will require to create the C file on notepad++ or in any of the file editor. Paste below mention code into the file and save it with .c extension.

Code: file name is hello.c


Compile and Run as follows

Linux: gcc -fopenmp -pthread hello.c && ./a.out

alternate way for linux

gcc -o hello -pthread hello.c

./hello

Windows MinGW: gcc -fopenmp -pthread hello.c && ./a.exe

Expected out put of the above code

Related link: https://stackoverflow.com/questions/7542286/how-to-run-pthreads-on-windows








Comments

Popular posts from this blog

Write a code to pass a simple integer to each thread and measure time taken by each thread with out and with pthread_join. The calling thread uses a unique data structure for each thread, insuring that each thread's argument remains intact throughout the program.

write simple code to create pthread and execute the code

print hello world using pthread through creating 5 threads.