I am trying to build all CUDA samples by running make
in the sample's base folder. One of the samples require mpi.h
, but the system did not have it, which causes an error:
make[1]: Entering directory '$HOME/cuda_samples/samples/0_Simple/simpleMPI'
/bin/mpicxx -I../../common/inc -o simpleMPI_mpi.o -c simpleMPI.cpp
simpleMPI.cpp:25:10: fatal error: mpi.h: No such file or directory
25 | #include <mpi.h>
| ^~~~~~~
compilation terminated.
make[1]: *** [Makefile:371: simpleMPI_mpi.o] Error 1
Since I don't have root privilege, I downloaded a deb file for libopenmpi-dev
package (using apt-get download
command) and extracted it to somewhere in my user space (using dpkg -x
command). However, as we can see, mpicxx
tries to find mpi.h
in ../../common/inc
, which is not where I installed libopenmpi-dev
in my user space (I did not notice that untill I installed the package. My bad). So I need to somehow tell mpicxx
to find mpi.h
in another directory. I know there is a -I
option to tell make
where additional include directories are, but this option does not apply to mpicxx
. How to pass directory information from make
's command line to mpicxx
is beyond my knowledge. Can you please teach me what option I should use in make
's command line to specify include directory used by mpicxx
? Of course I can manually copy the installed libopenmpi-dev
package to ../../common/inc
to accommodate original settings in CUDA sample, but I would like to do something cool and learn something new, so I ask here. Thank you in advance for teaching me.
Environment:
The include directory in Makefile is held in a variable INCLUDES
, together with -I
. So, if we can somehow transfer the include directory of mpi installed in my user space to this variable, we are done. So, the question is reduced to how to transfer a user-defined value from make
's command line into Makefile's variable and override it if it has be defined, as is clearly asked in the question.
Fortunately make
provides this command line option: VAR=value
, so the option to answer my question is
make INCLUDES=-I/path/to/mpi/include/in/my/user/space