编译包含 PETSc 库的 C++ 代码。 make: No rule to make target错误信息
Compiling a C++ code including PETSc libraries. make: No rule to make target error message
我对使用讨论的开源代码感兴趣 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 我做了以下更改:PETSC_DIR=\home\myusername\petsc
和 PETSC_ARCH=arch-linux-c-debug
。 运行 make -d topopt
之后出现以下错误:
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.
上面的代码只是整个消息的一小部分(开始部分和结束部分)。
我正在 Ubuntu 20.04.
提前致谢。
there exists a makefile_ref
where following the instructions given in the paper I make the following changes [...]
如果没有指定要读取的 makefile 的显式选项,make
实用程序会通过多个替代名称查找输入文件。 makefile_ref
不是其中之一。我将文件名的“_ref”部分作为“参考”的助记符,从这个角度来看,其意图似乎是将 makefile_ref
复制到 makefile
(其中一个文件名make
默认查找),并修改副本以适合您的环境。
答案:
嗯,事实证明编译GitHub上给出的拓扑优化代码毕竟不是那么复杂。
在这里,我重申了 GitHub 上的说明,并提供了更多细节。
要运行使用PETSc的拓扑优化开源代码首先需要安装PETSc。您应该注意,要安装 PETSc,您需要安装 BLAS 和 LAPACK 库,这非常简单,说明在 PETSc 中给出。现在系统上安装了 PETSc,只需从 GitHub.
克隆 TopOpt_in_PETSc
你会找到一个名为makefile_ref
的文件,将文件名改为makefile
然后打开它,在代码的前两行修改路径,就像这样这个 PETSC_DIR=/home/username/petsc
和 PETSC_ARCH=arch-linux-c-debug
(这是我的情况,可能因您的机器而异)。前一个命令是 PETSc 在本地计算机上安装目录的路径,后者是 PETSc 的构建名称。
完成上述操作后,您可以 运行 make topopt
它将为您构建一个名为 topopt
的可执行文件。按照 paper 中给出的说明,您将能够 运行 拓扑优化模拟。
备注:上面给出的安装说明是在 ubuntu 20.04 LTS 上执行的,尽管 PETSc 也与 Windows 和 iOS 甚至 Android 兼容。另一方面,TopOpt_in_PETSc 是在 linux 上开发和实现的,可能需要在 Windows 上安装进一步的操作。
我对使用讨论的开源代码感兴趣 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 我做了以下更改:PETSC_DIR=\home\myusername\petsc
和 PETSC_ARCH=arch-linux-c-debug
。 运行 make -d topopt
之后出现以下错误:
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.
上面的代码只是整个消息的一小部分(开始部分和结束部分)。
我正在 Ubuntu 20.04.
提前致谢。
there exists a
makefile_ref
where following the instructions given in the paper I make the following changes [...]
如果没有指定要读取的 makefile 的显式选项,make
实用程序会通过多个替代名称查找输入文件。 makefile_ref
不是其中之一。我将文件名的“_ref”部分作为“参考”的助记符,从这个角度来看,其意图似乎是将 makefile_ref
复制到 makefile
(其中一个文件名make
默认查找),并修改副本以适合您的环境。
答案:
嗯,事实证明编译GitHub上给出的拓扑优化代码毕竟不是那么复杂。 在这里,我重申了 GitHub 上的说明,并提供了更多细节。
要运行使用PETSc的拓扑优化开源代码首先需要安装PETSc。您应该注意,要安装 PETSc,您需要安装 BLAS 和 LAPACK 库,这非常简单,说明在 PETSc 中给出。现在系统上安装了 PETSc,只需从 GitHub.
克隆 TopOpt_in_PETSc你会找到一个名为makefile_ref
的文件,将文件名改为makefile
然后打开它,在代码的前两行修改路径,就像这样这个 PETSC_DIR=/home/username/petsc
和 PETSC_ARCH=arch-linux-c-debug
(这是我的情况,可能因您的机器而异)。前一个命令是 PETSc 在本地计算机上安装目录的路径,后者是 PETSc 的构建名称。
完成上述操作后,您可以 运行 make topopt
它将为您构建一个名为 topopt
的可执行文件。按照 paper 中给出的说明,您将能够 运行 拓扑优化模拟。
备注:上面给出的安装说明是在 ubuntu 20.04 LTS 上执行的,尽管 PETSc 也与 Windows 和 iOS 甚至 Android 兼容。另一方面,TopOpt_in_PETSc 是在 linux 上开发和实现的,可能需要在 Windows 上安装进一步的操作。