c++makefileubuntu-20.04finite-element-analysispetsc

Compiling a C++ code including PETSc libraries. make: No rule to make target error message


I am interested in using the open source code discussed here. The framework and some instruction on how to run the code is discussed here. To be able to use the code one should first install PETSc. I have done this and it seems to be correctly installed. The problem rises when I try to run make topopt following the instructions given in the paper (section 2.2). On the GitHub there exists a makefile_ref where following the instructions given in the paper I make the following changes: PETSC_DIR=\home\myusername\petsc and PETSC_ARCH=arch-linux-c-debug. After running make -d topopt I get the following error:

GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
 Considering target file 'GNUmakefile'.
  File 'GNUmakefile' does not exist.
  Looking for an implicit rule for 'GNUmakefile'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.o'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.c'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.cc'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.C'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.cpp'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.p'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.f'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.F'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.m'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.r'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.s'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.S'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.mod'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.sh'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile,v'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'RCS/GNUmakefile,v'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'RCS/GNUmakefile'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 's.GNUmakefile'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'SCCS/s.GNUmakefile'.
  Trying pattern rule with stem 'GNUmakefile'.
  Trying implicit prerequisite 'GNUmakefile.o'.
  Looking for a rule with intermediate file 'GNUmakefile.o'.
   Avoiding implicit rule recursion.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.c'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.cc'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.C'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.cpp'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.p'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.f'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.F'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.m'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.r'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.s'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.S'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.mod'.
   Trying pattern rule with stem 'GNUmakefile.o'.
   Trying implicit prerequisite 'GNUmakefile.o,v'.
   Trying pattern rule with stem 'GNUmakefile.o'.
   Trying implicit prerequisite 'RCS/GNUmakefile.o,v'.
   Trying pattern rule with stem 'GNUmakefile.o'.
   Trying implicit prerequisite 'RCS/GNUmakefile.o'.
   Trying pattern rule with stem 'GNUmakefile.o'.
   Trying implicit prerequisite 's.GNUmakefile.o'.
   Trying pattern rule with stem 'GNUmakefile.o'.
   Trying implicit prerequisite 'SCCS/s.GNUmakefile.o'.
   Trying pattern rule with stem 'GNUmakefile'.
   Trying implicit prerequisite 'GNUmakefile.c'.
   Looking for a rule with intermediate file 'GNUmakefile.c'.
    Avoiding implicit rule recursion.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem 'GNUmakefile'.
    Trying implicit prerequisite 'GNUmakefile.y'.
    Trying pattern rule with stem 'GNUmakefile'.
.
.
.
.
.
.
.
.
.
.
Looking for a rule with intermediate file 'topopt.mod'.
   Avoiding implicit rule recursion.
   Avoiding implicit rule recursion.
   Trying pattern rule with stem 'topopt.mod'.
   Trying implicit prerequisite 'topopt.mod,v'.
   Trying pattern rule with stem 'topopt.mod'.
   Trying implicit prerequisite 'RCS/topopt.mod,v'.
   Trying pattern rule with stem 'topopt.mod'.
   Trying implicit prerequisite 'RCS/topopt.mod'.
   Trying pattern rule with stem 'topopt.mod'.
   Trying implicit prerequisite 's.topopt.mod'.
   Trying pattern rule with stem 'topopt.mod'.
   Trying implicit prerequisite 'SCCS/s.topopt.mod'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.c'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.cc'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.C'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.cpp'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.p'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.f'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.F'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.m'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.r'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.s'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.S'.
 Trying pattern rule with stem 'topopt'.
 Rejecting impossible implicit prerequisite 'topopt.mod'.
 Trying pattern rule with stem 'topopt'.
 Trying implicit prerequisite 'topopt.sh'.
 Looking for a rule with intermediate file 'topopt.sh'.
  Avoiding implicit rule recursion.
  Trying pattern rule with stem 'topopt.sh'.
  Trying implicit prerequisite 'topopt.sh,v'.
  Trying pattern rule with stem 'topopt.sh'.
  Trying implicit prerequisite 'RCS/topopt.sh,v'.
  Trying pattern rule with stem 'topopt.sh'.
  Trying implicit prerequisite 'RCS/topopt.sh'.
  Trying pattern rule with stem 'topopt.sh'.
  Trying implicit prerequisite 's.topopt.sh'.
  Trying pattern rule with stem 'topopt.sh'.
  Trying implicit prerequisite 'SCCS/s.topopt.sh'.
 No implicit rule found for 'topopt'.
 Finished prerequisites of target file 'topopt'.
Must remake target 'topopt'.
make: *** No rule to make target 'topopt'.  Stop.

The code above is only a fraction of the whole message (the starting fraction and the ending fraction).

I am working on Ubuntu 20.04.

Thanks in advance.


Solution

  • ANSWER:

    Well it turns out that compiling the topology optimization code given on GitHub is not so complicated after all. Here I reiterate what has been given as instructions on GitHub with some more detail.

    To run the topology optimization open source code using PETSc one first needs to install PETSc. You should pay attention that to install PETSc you are going to need BLAS and LAPACK libraries installed, it is very straightforward and the instructions are given in PETSc. Now that PETSc is installed on the system one simply needs to clone TopOpt_in_PETSc from GitHub.

    You will find a file called makefile_ref, change the name of the file to makefile then open it and on the first two lines of the code modify the path, which would be something like this PETSC_DIR=/home/username/petsc and PETSC_ARCH=arch-linux-c-debug (this is in my case and could be different depending on your machine). The former ommand is the path to the directory where PETSc is installed on your local machine and the latter is the build name of PETSc.

    Once the above-mentioned manipulation is done you can run make topopt and it will build you an executable called topopt. Following the instructions given in the paper you will be able to run the simulations on topology optimization.

    REMARK: The installation instructions given above are performed on ubuntu 20.04 LTS, although PETSc is also compatible with Windows and iOS and even Android. On the other hand TopOpt_in_PETSc is developed and implemented on linux and propably needs further manipulation to be installed on Windows.