This what I get:
mingw32-gcc.exe -I"C:\Program Files\MPICH2\include" -c C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.c -o C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.o
mingw32-g++.exe -o C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.exe C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.o "C:\Program Files\MPICH2\lib\mpi.lib"
C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.o:main.c:(.text+0x38): undefined reference to `MPI_Init'
C:\Users\Almas\Desktop\OS_LAB1\MPI_TEST\main.o:main.c:(.text+0x4c): undefined reference to `MPI_Finalize'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings (0 minutes, 0 seconds)
Other than using your desktop to build the project; I see nothing wrong.
Did you download the right version of MPI.
The "http://www.mpich.org/static/tarballs/1.4.1p1/mpich2-1.4.1p1-win-ia32.msi" compiled for me on Windows 7 32 bit
I have no idea how to run the code; so never have ran it to see if it runs.
My build in case you can see the difference. Note: I compiled the example code from the website. I removed the warning from the build since the was not useful.
-------------- Build: Debug in testmpi (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -std=gnu++11 -Wall -fexceptions -g -Wmissing-include-dirs -I"C:\Program Files\MPICH2\include" -c V:\SourceCode\Projects\testmpi\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\testmpi.exe obj\Debug\main.o "C:\Program Files\MPICH2\lib\mpi.lib"
Output size is 944.50 KB
Still compiles after removing the unusual options I had set
mingw32-g++.exe -O2 -Wmissing-include-dirs -I"C:\Program Files\MPICH2\include" -c V:\SourceCode\Projects\testmpi\main.cpp -o obj\Release\main.o
mingw32-g++.exe -o bin\Release\testmpi.exe obj\Release\main.o -s "C:\Program Files\MPICH2\lib\mpi.lib"
Output size is 467.00 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings (0 minutes, 1 seconds)
Tim S.
Just a wild guess: it might be a name mangling problem.
Very good theory; but, I just changed it to C code. Note: This is NOT enough to rule out "name mangling" as the cause.
But, it reduces it as a possibility.
Edit3: I am using gcc version 4.7.1 (tdm-1) with SJLJ exceptions; I believe this is the version shipped with CB-mingw version 12.11.
#include <stdio.h>
#include "mpi.h"
#include <string.h>
int main(int argc, char *argv[])
{
int my_rank;
int size;
MPI_Init(&argc, &argv); /*START MPI */
/*DETERMINE RANK OF THIS PROCESSOR*/
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
/*DETERMINE TOTAL NUMBER OF PROCESSORS*/
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello world! I'm rank (processor number) %d of %d processor \n", my_rank, size);
MPI_Finalize(); /* EXIT MPI */
return 0;
}
And it still built OK.
mingw32-gcc.exe -O2 -Wmissing-include-dirs -I"C:\Program Files\MPICH2\include" -c V:\SourceCode\Projects\testmpi\main.c -o obj\Release\main.o
mingw32-g++.exe -o bin\Release\testmpi.exe obj\Release\main.o -s "C:\Program Files\MPICH2\lib\mpi.lib"
Output size is 9.00 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
Tim S.