Important notice! Before compiling your own solver, utility etc, first initialize OpenFOAM environment, see Initialization of OpenFOAM.
A good choice for creation of a new solver, is to start modifying an existing solver. In this example we choose existing icoFoam solver.
First, move to the user application directory. if the directory does not exist, create it (with mkdir command)
and create a directory solvers, i.e.
Copy existing icoFoam solver's source files, and move to the new directory consisting the source files to be modified.
cp -r $FOAM_SOLVERS/incompressible/icoFoam/ solvers/own_icoFoam
Rename icoFoam.C to own_icoFoam.C, i.e.
mv icoFoam.C own_icoFoam.C
and make your modification of the solver.
Start compilation, first editing (with emacs, vi, etc) the files file in the Make directory, i.e.
After edition, the file should look like this:
EXE = $(FOAM_USER_APPBIN)/own_icoFoam
Save the file, and in the own_icoFoam directory, give the compilation command
New executable is created. You may then move to your run directory and use the new solver executable, for example to run the cavity case with the existing input files, i.e.