none
Errors in very basic C++ program with Microsoft MPI RRS feed

  • Question

  • Hello all,

    I am a scientific programmer but very new to MPI. I am trying to make classic 'hello world' program on Windows OS, gcc with code::blocks IDE or VC++ compiler. The reason I am working with gcc is I am familiar with that and not with Visual Studio.

    Here the program goes:

    #include <iostream>
    #include <mpi.h>
    using namespace std;
    
    int main(int argc, char ** argv)
    {
    MPI_Init(&argc,&argv);
    cout<<"Hello World!"<<endl;
    MPI_Finalize();
    }

    Here is how I compiled the program

    g++ -o file file.cpp -I "C:\Program Files\Microsoft HPC Pack 2008 R2\Inc" -L "C:\Program Files\Microsoft HPC Pack 2008 R2\Lib\amd64" -lmsmpi -O3

    I tried hard to get some info and link, compile the program, however I get errors:

    undefined reference to `MPI_Init@8
    undefined reference to `MPI_Finalize@0

    Can anyone comment where I missed or mistaken something? Thanks a lot in advance!!



    • Edited by aert2020 Friday, June 20, 2014 11:20 AM changed title a bit
    Friday, June 20, 2014 11:19 AM

All replies

  • Are you building a 64-bit application, or a 32-bit application? The 64-bit symbols should not be decorated like your errors report. If you're building a 32-bit application, try using the 32-bit library path.

    -Fab

    Friday, June 20, 2014 8:41 PM
  • Thanks for reply. However I quite didn't get your message. I just used default gcc compiler, default code blocks, and used default Microsoft MPI libraries. Where the question of 32 or 64 bit arises? I am sorry if my question looks stupid to you, but that is my question. 

    Update: I have 64 bit OS. However 32 bit Microsoft MPI does not install on 64 bit system. Can you suggest what should I do?

    • Edited by aert2020 Friday, June 20, 2014 11:06 PM Update
    Friday, June 20, 2014 11:01 PM
  • What I meant was to try specifying -L "C:\Program Files\Microsoft HPC Pack 2008 R2\Lib\i386" instead of what you have currently.  I don't know if g++ defaults to building for 32-bit target (x86) or 64-bit target (x64).  The library path you specified is the x64 library path, and would cause linker issues if you built your files for x86.

    Hope that helps,
    -Fab

    Friday, June 20, 2014 11:05 PM
  • As you said, I have installed MPICH 32 bit (as Microsoft MPI 32 bit does not install) and tried to compile again. I changed directories accordingly. However the same error pops up. Any idea?
    Saturday, June 21, 2014 12:49 AM
  • When you install MS-MPI on an x64 Windows operating system, both the 32-bit and 64-bit DLLs are installed. The redistributable package also includes the libraries required to build both 32-bit and 64-bit applications. Did you try building with the -L linker path I suggested above?

    Thanks,
    -Fab

    Saturday, June 21, 2014 1:31 AM