I'm trying to build an executable from C++ source code which uses MPI, on a GNU/Linux Devuan Chimaera system. Now, I'm an MPI/OpenMP newbie, I'm just trying to adapt this code, which isn't mine, to be built with CMake - when before it had a Makefile
. My build succeeds, but I'm seeing segfaults, so I want to make sure my problem isn't with the build phase, which bugs me.
My CMakeLists.txt
has:
find_package(OpenMP REQUIRED)
find_package(MPI REQUIRED)
and my system has OpenMPI 4.1.1 installed, which is found. I do this for my target:
target_link_libraries(my_executable PRIVATE MPI::MPI_CXX OpenMP::OpenMP_CXX)
but nothing else which indicates its expecting to be compiled by mpicxx.
... and indeed, when I configure (with CMake 3.22.1) and then build, the usual c++
executable gets invoked to compile (and then link) the my_target
executable.
Questions:
- Can source code which originally was getting compiled with
mpicxx
be compiled with "just" a C++ compiler, with the appropriate includes? - Assuming there's any merit to using
mpicxx
for compilation - how do I get CMake to use it for my target?
Edit: It's been suggested to me to try using mpirun
to run my program. With it, I get no segmentation faults, consistently; it's only when I run directly that I see them.