makefile - 'make' 找不到头文件

标签 makefile compiler-errors mpi petsc

make指令未找到编译所需的库。它们位于不同于通常 /usr/include 的其他文件夹中文件夹。
我正在遵守一个名为 magnum.fe 的模拟软件我已经安装了所有必需的依赖项(FEniCS = 1.5
CMake >= 2.8
痛饮 >= 2.0
G++ >= 4.0) 并开始运行make正如说明所建议的那样。

$ cd /path/to/magnum.fe
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
但是在运行 make 时出现以下错误:
/usr/include/petscsys.h:136:12: fatal error: petsc/mpiuni/mpi.h: No such file or directory
  136 | #  include <petsc/mpiuni/mpi.h>
      |            ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
文件确实存在,但在其他文件夹中:/home/myusername/bin/petsc/include/mpiuni/mpi.h我编译了petsc/home/myusername/bin/petsc/使用以下说明:
$ ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack
$ make all check
它编译成功,但我无法完成 magnum.fe 编译。
我尝试将每个头文件移动到 /usr/include但是现在如果将整个 petsc 目录移动到此文件夹中,我会坚持下去。它必须是一种更优雅的方式。
谢谢

最佳答案

我成功了!
有两种选择:
指定库 要与编辑 MAKEfile 的 make 命令一起使用,请使用变量 LDLIBS设置它。详细用法在这里:https://web.archive.org/web/20070723140628/http://arco.inf-cr.uclm.es/~david.villa/doc/repo/make/make.html#AEN36
或者
创建符号链接(symbolic link) 指向/usr/include .就我而言,我使用了:

ln -s /home/myusername/bin/petsc/include/* /usr/include

关于makefile - 'make' 找不到头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65160066/

相关文章:

c - 原始数据的指针运算

makefile - 如何防止 Webpack 从 Makefile 配方中多次运行

编译错误 fatal error : sys\types. h : No such file or directory #include <sys\types. h>

c++ - 使编译在模板类的特定实例化时失败

c++ - 使用 MPI 进行并行编程以使用动态二维数组进行矩阵乘法时如何解决问题?

c++ - 如何在 MPI 中创建新类型

c - Makefile 找不到已经存在的目标

c - 通过 C 中的 makefile linux/unix 命令行传递参数

c - 动态库动态附加

c++11 - 如何解决在此范围内未声明的 “' shared_ptr错误?