User forums > Help

C programming with MPI.H

(1/2) > >>

Clipper_101:
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!

stahta01:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Clipper_101:
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)
 

stahta01:

--- 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)

--- End quote ---

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.


--- Code: ----------------- 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

--- End code ---

Still compiles after removing the unusual options I had set

--- Code: ---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)

--- End code ---


Tim S.

stahta01:
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. 

--- Code: ---#include "mpi.h"

--- End code ---

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version