3

Always get the following errors while running the OpenMPI command "mpicxx hello_cxx.cc -o hello"

hello_cxx.cc: In function ‘int main(int, char**)’: 
hello_cxx.cc:25:5: error: ‘MPI’ has not been declared
     MPI::Init();
     ^~~ hello_cxx.cc:26:12: error: ‘MPI’ has not been declared
     rank = MPI::COMM_WORLD.Get_rank();
            ^~~ hello_cxx.cc:27:12: error: ‘MPI’ has not been declared
     size = MPI::COMM_WORLD.Get_size();
            ^~~ hello_cxx.cc:31:5: error: ‘MPI’ has not been declared
     MPI::Finalize();
     ^~~
4
  • To help it would really help to see the code of and not only the couple lines that you put up here. Commented Sep 25, 2017 at 19:49
  • Also it would help to know what OS, which version of OpenMPI you use. Commented Sep 25, 2017 at 20:00
  • I have tried 3 different versions, all are version 2 or later in Ubuntu Kylin 17.04. Commented Oct 3, 2017 at 5:34
  • Since it didn't help at all, I tried installing a fresh "Ubuntu GNOM 17.04" OS and "openmpi-2.1.1". But, it didn't help following a regular process of installation and then enabling "--enable-mpi-cxx". So, after installation and enabling "--enable-mpi-cxx" I rebuild it with "sudo make install" command and it worked fine. Commented Oct 3, 2017 at 5:43

2 Answers 2

4

Your application is using MPI C++ bindings. Keep in mind C++ bindings have been removed from the MPI standard.

From an Open MPI point of view, C++ bindings are still here, but they are no more built be default since Open MPI 2.0.0.

So if you are using Open MPI 2.0.0 or later, you first need to make sure C++ bindings were built. If not, you need to rebuild Open MPI, and configure with the --enable-mpi-cxx option.

On the long term, you should really move away from MPI C++ bindings. You can either use plain C bindings, or explore alternate C++ bindings such as the popular Boost:MPI library.

Sign up to request clarification or add additional context in comments.

Comments

0

I also meet the problem,but I don't have root privileges. As the before answer mentioned , Open MPI 2.0.0 has changed the build mode.So you just need to change the grammar.

I meet the error:

error: ‘MPI’ has not been declared

mpifile = MPI::FILE_NULL;

From the openmp 2.0 api:

http://mpi-forum.org/docs/mpi-2.0/mpi-20-html/node217.htm#Node217

I find the new error handle is MPI_FILE_NULL.I change it directly in my code and then it works.

The next link is about the Deprecated since MPI-2.2:

http://mpi-forum.org/docs/mpi-2.2/mpi22-report/node328.htm#Node328

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.