Attempting to compile through MacOS Terminal: "No such file or directory"

674 Views Asked by At

I'm trying to compile this project from DTU. This project requires that PETSc be installed.

I have installed PETSc to /Users/hornymoose/petsc-3.13.3/

I have extracted the zip from GitHub to /Users/hornymoose/dtu

The DTU project's makefile has the following lines:

include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules
include ${PETSC_DIR}/lib/petsc/conf/test

In these lines, {PETSC_DIR} is to be substituted with the user's PETSc installation directory. Thus, I changed these lines to:

include $/Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables
include $/Users/hornymoose/petsc-3.13.3/lib/petsc/conf/rules
include $/Users/hornymoose/petsc-3.13.3/lib/petsc/conf/test

To compile the code, I write make topopt in Terminal. Doing so yields:

makefile:13: Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables: No such file or directory
makefile:14: Users/hornymoose/petsc-3.13.3/lib/petsc/conf/rules: No such file or directory
makefile:15: Users/hornymoose/petsc-3.13.3/lib/petsc/conf/test: No such file or directory
make: *** No rule to make target `Users/jhutopopt/petsc-3.13.3/lib/petsc/conf/test'.  Stop.

I have gone back and manually checked that Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables, ...rules, and ...test definitely exist and do not have errors.

Why am I receiving this error? Am I indicating the directory incorrectly in my makefile? Is the syntax in the makefile incorrect?

I'm sure there is a simple solution, I'm just very new to working with Terminal in MacOS. Thank you in advance!

1

There are 1 best solutions below

2
On

There is a $ in the paths:

include $/Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables
        ^

This causes the / to be treated as a variable, and expanded to nothing because was never set. Run make with option --warn-undefined-variables to get a warning on that sort of thing. Perhaps already obvious at this point, but the correct line would be:

include /Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables

Rather than manually substituting the PETSC_DIR in the makefile you can provide it through an environment variable (assuming PETSc makefiles aren't bad):

export PETSC_DIR=/Users/hornymoose/petsc-3.13.3
make topopt

...or:

PETSC_DIR=/Users/hornymoose/petsc-3.13.3 make topopt

...or pass its value to the make invocation:

make topopt PETSC_DIR=/Users/hornymoose/petsc-3.13.3