Reputation: 468
I am trying to run a CMakeLists.txt file on a (48h) fresh ubuntu 20.04.3 install. I keep getting the following error when running cmake .
-- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS)
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find MPI (missing: MPI_CXX_FOUND) (found version "3.1")
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindMPI.cmake:1688 (find_package_handle_standard_args)
CMakeLists.txt:16 (find_package)
-- Configuring incomplete, errors occurred!
As far as I can tell the relevant lines in CMakeLists.txt are the following:
# check MPI package...
find_package(MPI REQUIRED)
set(CMAKE_CXX_COMPILER mpicxx)
include_directories(${MPI_INCLUDE_DIR})
I have tried to resolve this by installing through apt mpich
. Although the install works and running mpich --version
returns (below) the error persists.
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cmake --version
returns 3.16.3
I have made restart(s) since installing each package. I have also added to my ~/.bashrc
export PATH=$PATH:/usr/bin/mpicc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/bin/mpicc
which also seems to have done nothing (this after a restart again).
If relevant, I have also installed through apt cmake, libboost-all-dev, cuda-10-1, libcudnn7, libblas-dev, liblapack-dev, mpi
I would appreciate any help in the matter.
Upvotes: 6
Views: 29945
Reputation: 71
Setting CMAKE_PREFIX_PATH
did not solve my problem. I got it solved by using the variable CMAKE_C_COMPILER
and CMAKE_CXX_COMPILE
mentioned in this issue: https://github.com/3dem/relion/issues/702
As such, my cmake command now looks like:
cmake -DCMAKE_C_COMPILER=/home/user/opt/openmpi/bin/mpicc -DCMAKE_CXX_COMPILER=/home/user/opt/openmpi/bin/mpicxx .
, where /home/user/opt/openmpi/bin
is the location of your MPI binaries.
Upvotes: 3
Reputation: 176
Use CMAKE_PREFIX_PATH variable to set search path. Best practice is set that variable in command line interface:
mkdir build
cd build
cmake -G "Unix Makefiles" .. -DCMAKE_PREFIX_PATH=path_to_mpi_lib
Anyway you can set the following variables for locating MPI before find_package command (description from FindMPI.cmake):
``MPIEXEC_EXECUTABLE``
Manually specify the location of ``mpiexec``.
``MPI_HOME``
Specify the base directory of the MPI installation.
``ENV{MPI_HOME}``
Environment variable to specify the base directory of the MPI installation.
``ENV{I_MPI_ROOT}``
Environment variable to specify the base directory of the MPI installation.
Upvotes: 7