Fatal Error: mpi.h No such file or directory
Asked Answered
A

0

6

I'm a new linux user. I'm getting this error during compilation. When I use the 'make' command within a build directory.

Fatal Error: mpi.h No such file or directory

I've installed OpenMpi using this:

sudo apt install libopenmpi-dev

I found the folder where mpi.h is located: and I attempted to add it to path:

export PATH=$PATH:/usr/lib/x86_64-linux-gnu/openmpi/include

I still get the same error when I try 'make'. What am I doing wrong? Thanks.

Edit: I think I'm using the G++ compiler, here's the full error message:

 Making all in Ipopt
make[1]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt'
Making all in src/Common
make[2]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Common'
make  all-am
make[3]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Common'
make[3]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Common'
make[2]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Common'
Making all in src/LinAlg
make[2]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg'
Making all in TMatrices
make[3]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg/TMatrices'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg/TMatrices'
make[3]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg'
make[2]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/LinAlg'
Making all in src/Algorithm
make[2]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Algorithm'
Making all in LinearSolvers
make[3]: Entering directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Algorithm/LinearSolvers'
if /bin/bash ../../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers` -I../../../src/Common  -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/../../Common` -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/../../LinAlg` -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/../../LinAlg/TMatrices` -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/..` -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/../../Interfaces` -I`echo ../../../../../Ipopt/src/Algorithm/LinearSolvers/../../contrib/CGPenalty` -I/home/rory/Packages/Ipopt/include/coin-or/mumps    -O3 -pipe -DNDEBUG -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long   -DIPOPT_BUILD -MT IpMumpsSolverInterface.lo -MD -MP -MF ".deps/IpMumpsSolverInterface.Tpo" -c -o IpMumpsSolverInterface.lo ../../../../../Ipopt/src/Algorithm/LinearSolvers/IpMumpsSolverInterface.cpp; \
then mv -f ".deps/IpMumpsSolverInterface.Tpo" ".deps/IpMumpsSolverInterface.Plo"; else rm -f ".deps/IpMumpsSolverInterface.Tpo"; exit 1; fi
 g++ -DHAVE_CONFIG_H -I. -I../../../../../Ipopt/src/Algorithm/LinearSolvers -I../../../src/Common -I../../../../../Ipopt/src/Algorithm/LinearSolvers/../../Common -I../../../../../Ipopt/src/Algorithm/LinearSolvers/../../LinAlg -I../../../../../Ipopt/src/Algorithm/LinearSolvers/../../LinAlg/TMatrices -I../../../../../Ipopt/src/Algorithm/LinearSolvers/.. -I../../../../../Ipopt/src/Algorithm/LinearSolvers/../../Interfaces -I../../../../../Ipopt/src/Algorithm/LinearSolvers/../../contrib/CGPenalty -I/home/rory/Packages/Ipopt/include/coin-or/mumps -O3 -pipe -DNDEBUG -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -DIPOPT_BUILD -MT IpMumpsSolverInterface.lo -MD -MP -MF .deps/IpMumpsSolverInterface.Tpo -c ../../../../../Ipopt/src/Algorithm/LinearSolvers/IpMumpsSolverInterface.cpp  -fPIC -DPIC -o .libs/IpMumpsSolverInterface.o
../../../../../Ipopt/src/Algorithm/LinearSolvers/IpMumpsSolverInterface.cpp:22:10: fatal error: mpi.h: No such file or directory
 #include "mpi.h"
          ^~~~~~~
compilation terminated.
Makefile:569: recipe for target 'IpMumpsSolverInterface.lo' failed
make[3]: *** [IpMumpsSolverInterface.lo] Error 1
make[3]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Algorithm/LinearSolvers'
Makefile:688: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt/src/Algorithm'
Makefile:679: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/rory/Packages/Ipopt/build/Ipopt'
Makefile:323: recipe for target 'all-recursive' failed
Aquarius answered 3/2, 2021 at 19:44 Comment(6)
You need to set the C++ compiler to mpic++. It is a wrapper around the system C++ compiler that passes it all the necessary arguments needed to find the MPI header file and link the necessary MPI libraries. That's usually achieved by setting the CXX variable in the environment.Illdisposed
Thanks. Would you mind telling me the command line to do this I'm very new? I've only set environments variables before with expor X='Y' Also I don't appear to have a CXX environment variable at the moment, is this abnormal?Aquarius
export CXX=mpic++ && make or simply CXX=mpic++ make. CXX is not normally set in the environment, in which case make uses the default value.Illdisposed
@HristoIliev Hmm it seems to not have worked.Aquarius
@HristoIliev Nevermind, you solved it. But I had to go back a ./configure again before I could make.Aquarius
Well, if your Makefile is generated by GNU Autotools, you have to set CXX when running the configure script.Illdisposed

© 2022 - 2024 — McMap. All rights reserved.