1

I have Windows 8 64bit operating system.

I wanted to experiment with following C code for OpenMP functionality:

hello.c program

#include <stdio.h>
#include <stdlib.h>
#include<omp.h>

int main()
{
    #pragma omp parallel
    printf("Hello world!\n");
    return 0;
}

While I tried to run the program from command prompt using: gcc -fopenmp hello.c

I got the following error:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lpthread
collect2.exe: error: ld returned 1 exit status

I have C:\MinGW in my path with gcc 4.8.1.

What is it I am missing?

1

2 Answers 2

1

Thanks osgx,

As a newbie I couldn't make out what these pthreads meant. But after all I found solution to my problem. I installed gcc 4.8.2 64 bit on my machine from http://www.equation.com/servlet/equation.cmd?fa=fortran. It changed the environment variable (in path) itself. After finishing installation, I restarted my computer and when I typed:

gcc -fopenmp hello.c

for the above code in command line, the code worked.

Sign up to request clarification or add additional context in comments.

Comments

0

The other trick is to use docker container with gcc.

Steps:

  1. Install docker
  2. In the docker terminal: docker pull gcc
  3. Then run a terminal and mount a host folder where your C scripts are inside the gcc container by typing: docker run -it -v /hostfolder:/folderincontainer gcc /bin/bash
  4. Then execute the script in the terminal.

Its simple. No need to worry about the specifics of OS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.