makefile - 使用 makefile 编译具有不同文件夹中的源文件的程序
问题描述
所以我一直在尝试使用这个已发布问题的答案和想法:Makefile: Compiling from directory to another directory
在以下摘录代码中,您可以看到目录的定义,用于源和编译对象。
all : Mpois Mkvz MBJ Mlid
# Definitions
COMPILER := gfortran -O3
LIBS := -g -fbounds-check -ffast-math -lm
# Directories of object code
OBJDIR = objects
SRCDIR = src
SOURCES := $(SRCDIR)/lbm_const.f90 $(SRCDIR)/BORDERS.f90 $(SRCDIR)/CONVERGENCE.f90 $(SRCDIR)/FILESIO.f90 $(SRCDIR)/LBM.f90
OBJECTS := $(OBJDIR)/lbm_const.o $(OBJDIR)/BORDERS.o $(OBJDIR)/CONVERGENCE.o $(OBJDIR)/FILESIO.o $(OBJDIR)/LBM.o
SOURCES_pois := $(SRCDIR)/Main_pois.f90
OBJECTS_pois := $(OBJDIR)/Main_pois.o
# Linking
Mpois: $(OBJECTS) $(OBJECTS_pois)
$(COMPILER) $^ -o $@ $(LIBS)
# Compiling
$(OBJECTS): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
# Compiling
$(OBJECTS_pois): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
clean:
rm -f $(OBJDIR)/*.o
rm -f $(OBJDIR)/*.mod
rm -f $(SRCDIR)/*.mod
运行 makefile 脚本时出现以下错误:
make: *** No rule to make target 'lbm_const.f90', needed by 'objects/lbm_const.o'. Stop.
有趣的是,当对 makefile 的SRCDIR = src
更改SRCDIR = .
编译时,即使文件夹 src 中有文件。
解决方案
推荐阅读
- api - 对 API 更改感到困惑
- java - Spring WebFlux 块 Http.CONNECT 方法
- javascript - Cordova 未反映 js 文件中的更改
- powershell - 如何通过他们的 InstanceID 选择事件日志
- php - 将 md5 更新为 sha512 授权网
- c# - wpf UserControl在ItemsControl中具有自适应高度
- java - 如何在扩展的 EditText 上的嵌套 onClick 中调用 super.setText?
- javascript - 在 javascript 函数中创建的按钮的事件侦听器/onclick 事件
- stripe-payments - 在创建订单时指定运费 - Stripe
- angular - 中断角度动画时出现“无法读取属性 '_view' of null”错误