我有以下makefile:
CC=g++
CFLAGS=-I.
tiling_file=blocking.cpp
sequential_file=sequential.cpp
n1 = 100
n2=7
n3=4
all: tiling sequential run
tiling:
$(CC) $(tiling_file) -fopenmp -o block
sequential:
$(CC) $(sequential_file) -fopenmp -o seq
run:
./block $(n1) $(n2) $(n3)当执行make时,块可执行文件接受三个输入(由n1、n2、n3指定) .However,得到以下输出
g++ blocking.cpp -fopenmp -o block
g++ sequential.cpp -fopenmp -o seq
./block 100 7 4 除非我再次键入100 7 4并按enter键,否则可执行文件不会接受输入。我怎么能运行它?
发布于 2016-11-22 15:31:08
除非我再次键入100 7 4并按enter键,否则可执行文件不会接受输入。我怎么能运行它?
该可执行文件可能期望它的标准输入而不是命令行参数中的数据:
run:
echo "$(n1) $(n2) $(n3)" | ./block 对于运行可执行文件,我通常有以下规则:
run_% : %
echo "${$*.stdin}" | ./$< ${$*.args}
.PHONY: run_%然后我定义了一个可执行文件:
mytest : # something that builds mytest executable
mytest.stdin := "this goes into the standard input of mytest"
mytest.args := --verbose --dry-run然后像这样调用:
make run_mytest另外一点是,您的食谱必须生成他们承诺要生成的文件。目前,它承诺构建一个名为tiling的文件,但将构建一个名为block的文件。
修复:
tiling:
$(CC) $(tiling_file) -fopenmp -o $@
sequential:
$(CC) $(sequential_file) -fopenmp -o $@在上面的$@中,tiling和sequential相应地表示目标名称。
https://stackoverflow.com/questions/40745729
复制相似问题