【问题标题】:Attempting to compile through MacOS Terminal: "No such file or directory"尝试通过 MacOS 终端编译:“没有这样的文件或目录”
【发布时间】:2020-07-10 22:51:45
【问题描述】:

我正在尝试编译this project from DTU。该项目需要安装PETSc

我已将 PETSc 安装到 /Users/hornymoose/petsc-3.13.3/

我已经从 GitHub 解压 zip 到 /Users/hornymoose/dtu

DTU 项目的makefile 有以下几行:

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

在这些行中,{PETSC_DIR} 将替换为用户的 PETSc 安装目录。因此,我将这些行改为:

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

为了编译代码,我在终端中写了make topopt。这样做会产生:

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.

我已经回去手动检查了Users/hornymoose/petsc-3.13.3/lib/petsc/conf/variables...rules...test确实存在并且没有错误。

为什么我会收到此错误消息?我是否在makefile 中错误地指示了目录? makefile 中的语法不正确吗?

我确信有一个简单的解决方案,我对在 MacOS 中使用终端非常陌生。提前谢谢!

【问题讨论】:

    标签: macos makefile terminal parallel-processing petsc


    【解决方案1】:

    路径中有$

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

    这会导致/ 被视为变量,并扩展为空,因为从未设置。使用选项 --warn-undefined-variables 运行 make 以获取有关此类事情的警告。也许在这一点上已经很明显了,但正确的行应该是:

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

    您可以通过环境变量提供它,而不是手动替换 makefile 中的 PETSC_DIR(假设 PETSc makefile 还不错):

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

    ...或:

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

    ...或将其值传递给 make 调用:

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

    【讨论】:

    • 谢谢 Andreas,将 PETSC_DIR 设置为环境变量效果很好 - 特别是因为变量、规则和测试文件也引用了 PETSC_DIR。
    • @hornymoose 很高兴听到这个消息! :)
    猜你喜欢
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 2015-10-14
    • 1970-01-01
    相关资源
    最近更新 更多