如何在编译Castro库时绕过M_PI错误而不影响代码?
我安装了 castro库用于天文学建模,我遵循描述的构建设置在这里。我成功地更改了gnumakefile中的参数(如本教程中所述),但是当我运行命令make
.... castro/exec/exec/hydro_tests/sedov 目录目录时,我遇到了几个错误,其中大多数是'm_pi'在此范围
中没有声明。我谷歌搜索了该错误,大多数答案是指构建自己的代码(一个文件,左右)。主要原因很清楚:我正在使用MS东西(我正在运行Windows,安装了G ++和VS编译器)和m_pi
默认不支持。相反,我应该定义_USE_MATH_DEFINES
。
问题是我想拥有一个方便的解决方案:我不想搜索m_pi
的每个实例并替换它,或添加到每个文件#define _use_math_math_defines
。相反,我想更改make
命令,以便在每个文件中定义_USE_MATH_DEFINES
。不幸的是,我尚未使用MAKE
太多,所以我不知道该怎么做。
gnumakefile
(这是唯一的make
相关文件)无济于事:
PRECISION = DOUBLE
PROFILE = FALSE
DEBUG = FALSE
DIM = 2
COMP = gnu
USE_MPI = FALSE
USE_OMP = FALSE
USE_MHD = FALSE
USE_FORT_MICROPHYSICS := FALSE
BL_NO_FORT := TRUE
# define the location of the CASTRO top directory
CASTRO_HOME := ../../..
# This sets the EOS directory in $(MICROPHYSICS_HOME)/EOS
EOS_DIR := gamma_law
# This sets the network directory in $(MICROPHYSICS_HOME)/Networks
NETWORK_DIR := general_null
NETWORK_INPUTS = gammalaw.net
Bpack := ./Make.package
Blocs := .
include $(CASTRO_HOME)/Exec/Make.Castro
因此,我要求您提供正确的make> make
命令,或给出绕过错误的任何其他选择。
I installed the Castro library for astronomical modelling, and I followed the build setup described here. I successfully changed the parameters in GNUmakefile (as described in the tutorial), but when I ran the command make
in ....Castro/Exec/hydro_tests/Sedov
directory, I got several errors, the majority of them being 'M_PI' was not declared in this scope
. I googled about the error, and the majority of the answers were referring to building of own code (one file, or so). The main reason was clear: I am using MS stuff (I am running Windows, with installed g++ and VS compiler) and M_PI
is not supported by default. Instead, I should define _USE_MATH_DEFINES
.
The problem is that I want to have a convenient solution: I don't want to search for every instance of M_PI
and replace it, or add to every file #define _USE_MATH_DEFINES
. Instead, I want to alter the make
command so that _USE_MATH_DEFINES
is defined in every file. Unfortunately, I haven't yet used make
much, so I don't know how to do this.
The GNUmakefile
(which is the only make
-related file) doesn't help much:
PRECISION = DOUBLE
PROFILE = FALSE
DEBUG = FALSE
DIM = 2
COMP = gnu
USE_MPI = FALSE
USE_OMP = FALSE
USE_MHD = FALSE
USE_FORT_MICROPHYSICS := FALSE
BL_NO_FORT := TRUE
# define the location of the CASTRO top directory
CASTRO_HOME := ../../..
# This sets the EOS directory in $(MICROPHYSICS_HOME)/EOS
EOS_DIR := gamma_law
# This sets the network directory in $(MICROPHYSICS_HOME)/Networks
NETWORK_DIR := general_null
NETWORK_INPUTS = gammalaw.net
Bpack := ./Make.package
Blocs := .
include $(CASTRO_HOME)/Exec/Make.Castro
I, therefore, ask you to give the correct make
command, or give any other option of bypassing the error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:正如@madscientist指出的那样,
的位置在命令行中定义=
:make devers = ...
是我最初有第一种形式,这是错误的。
看来该系统扩展了预处理程序定义
定义
变量的设置,因此以下内容应该有效:如果您不想每次键入该变量,则可以进行
一次,然后致电
Make
几次。EDIT: as @MadScientist points out, the position of
DEFINES=
in the commandline matters:make DEPENDS=...
is an overriding variable which ignores extensionsDEPENDS=... make
sets a value from the environment which is fine.I originally had the first form, which is wrong.
It looks like that system extends preprocessor defines set in the
DEFINES
variable, so the following should work:If you don't want to type that everytime, you can do
once and then call
make
several times.