I have a C MPI program that runs well but my challenge is to compile it with a Makefile. The C file is named frequencyMPI.c and I have drafted the Make file named makefile.frequencyMPI. The makefile successfully compiled on Linux terminal but I don't know how to run it. My problem is how to run it and whether it is correct. The content of the Makefile is given below:
all: program
program: frequencyMPI.o
mpicc frequencyMPI.o -o program
frequencyMPI.o: frequencyMPI.c
mpicc -c frequencyMPI.c -o frequencyMPI.o
clean:
rm -f frequencyMPI.o program core *~
makeorgmake, specifying your Makefile with-f makefile.frequencyMPI? 2. Have you considered using CMake instead, and letting it generate the Makefile for you? Here is an explanation on how to do that. It also takes care of locating relevant libraries if they are not in the include path already. 3. Are you sure you want to run the mpicc wrapper rather than compiling directly?make -f makefile.frequencyMPIit did not give any errorsmake, which uses the instructions in the makefile to build your software. The above makefile builds a program namedprogram. Did you try to run that program? If the problem is that it didn't work then we need to know, what did you type? What errors did you get?make -f makefile.frequencyMPIit generated frequencyMPI.o in the directory. I tried running it with./frequencyMPI.oit says permission denied then i triedsudo ./frequencyMPI.othen it says command not found. Normally when I compile withmpiccon terminal I run withmpirun -np 3 ./frequencyMPI.obut for a make file executable, I don't know how to execute it to know if it correct. Secondly, my program is not namedprogram, it is namedfrequencyMPI.cfrequencyMPI.c. That's the source code for your program. AlsofrequencyMPI.ois not a program either and cannot be run from the command line, it's an object file which represents the compiled version of your source code. Then you have to link that object file into a program, or executable file, that you have namedprogramhere. Then you can run the executable file.