Hello to all!
I have collided with some problems, I installed MPICH2 and followed this instructions: http://ru.scribd.com/doc/50326868/MPICH2-Code-Blocks-IDE I also added the C:\Program Files\MPICH2\bin to PATH system variable
But Codeblocks can't build my programm, errors are undefined reference to MPI_Init, MPI_Finalize
Here is the sample code:
#include <stdio.h>
#include <mpi.h>
main(int argc, char **argv)
{
int ierr;
ierr = MPI_Init(&argc, &argv);
printf("Hello world\n");
ierr = MPI_Finalize();
}
Can someone say why Codeblocks refuses to work with MPI? My system works on Windows 7 HP 64bit's, Codeblocks and MPICH2 are also 64 bits. Really hope on your help. Thanks in advance!
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
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)
Quote from: Clipper_101 on February 26, 2013, 02:04:04 PM
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.
For any more progress the MPICH2 version and Compiler version will be needed.
FYI: I am using this like the web page example; it does not make a difference with my setup; but, it might with yours.
#include "mpi.h"
Tim S.
Just a wild guess: it might be a name mangling problem.
Quote from: jens on February 26, 2013, 03:34:46 PM
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.
maybe a 32/64 bit issue ?