如何在编译Castro库时绕过M_PI错误而不影响代码?

发布于 2025-02-08 10:03:57 字数 1539 浏览 0 评论 0原文

我安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

念﹏祤嫣 2025-02-15 10:03:57

编辑:正如@madscientist指出的那样,的位置在命令行中定义=

  • make devers = ...
  • ​href =“ https://www.gnu.org/software/make/manual/make.html#environment” rel =“ nofollow noreferrer”>“ nofollow noreferrer”>来自环境的值很好。

我最初有第一种形式,这是错误的。

看来该系统扩展了预处理程序定义定义变量的设置,因此以下内容应该有效:

DEFINES=-D__USE_MATH_DEFINES make

如果您不想每次键入该变量,则可以进行

export DEFINES=-D__USE_MATH_DEFINES

一次,然后致电
Make几次。

EDIT: as @MadScientist points out, the position of DEFINES= in the commandline matters:

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:

DEFINES=-D__USE_MATH_DEFINES make

If you don't want to type that everytime, you can do

export DEFINES=-D__USE_MATH_DEFINES

once and then call
make several times.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文