i keep getting error :
fatal error: mpi.h: No such file or directory
how do i include mpi.h
as a default library?
i believe i'd already put c:\MPICH2\bin
on system variable>path
The compiler can't find the header file. The system PATH variable is not related to this.
In order to run the compiler it needs to be on the system PATH (this is where the OS looks up "gcc" when you type it on the command line). Once GCC is running, it needs to know where header files can be found. You can add an include path with the -I
flag:
gcc -I"C:/Program Files (x86)/MPICH2/include" -c -o main.o main.c
Once that's done, and everything is compiled, the next step is to link the program. You will need to specify a path to the library with the -L
flag:
gcc -L"C:/Program Files (x86)/MPICH2/lib" -o main.exe main.o -lmpi
Normally this is handled by the mpicc
script so you don't have to worry about this. The mpicc
that ships with the pre-built Windows MPICH2 won't work with MinGW out of the box though (I think).