gpt4 book ai didi

c++ - 将 Boost 与 Makefile/缺少分隔符一起使用

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:24:21 25 4
gpt4 key购买 nike

我是制作文件和 Boost 的新手,我正在尝试关注 this教程,特别是 Makefile4。

我只有两个源文件,分别是S1.cppmain.cpp所在位置,和GaussQuadrature.h。现在,GaussQuadrature.h 还使用了一个 Boost 文件,所以(据我所知)我必须告诉编译器 Boost 所在的位置,这是我的源文件所在的两个目录。我的生成文件是

CC=g++
CFLAGS=-o2 -std=c++0x
DEPS = GaussQuadrature.h
OBJ = S1.o

%.o: %.cpp $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)

S1: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) S1.o -o S1 -I ../../boost_1_55_0

当我运行 make 命令时出现错误

makeS1:7: *** missing separator.  Stop.

我读到这最常见的原因是命令缺少制表符(有趣的是,当我点击“制表符”时,上面两个命令的缩进方式不同),但即使我将它们更改为

%.o: %.cpp $(DEPS)
\t$(CC) -c -o $@ $< $(CFLAGS)

S1: $(OBJ)
\t$(CC) -o $@ $^ $(CFLAGS) S1.o -o S1 -I ../../boost_1_55_0

我得到了同样的错误。

除了修复此错误之外,将 Boost 目录包含在 makefile 中的正确方法是什么,或者是否有办法完全包含它?谢谢!

最佳答案

与Boost无关。 Makefile 需要制表符

http://www.delorie.com/djgpp/v2faq/faq22_17.html

Unlike most other DOS Make programs which accept any whitespace character at the beginning of a command in a rule, GNU Make insists that every such line begins with a TAB. (Most other Unix Make programs also require TABs, and the Posix standard requires it as well.) Make sure that the line whose number is printed in the error message (in this case, line 10) begins with a TAB.

关于c++ - 将 Boost 与 Makefile/缺少分隔符一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21519577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com