包含在 gnu make 文件中被忽略的路径

发布于 2024-10-12 19:12:43 字数 1655 浏览 2 评论 0原文

生成文件包含在下面。它只是一长串目标文件和两个目标。问题似乎是第一个目标的 $(INC) 被忽略。例如,输出以“g++ -c -o main.o main.cpp”开头,而不是“g++ -I/usr/home/jrm/tmp/proteus_beta -c -o main.o main.cpp”。

TIA

PROG = proteus

# list of object files
OBJS = main.o \
dataset.o \
genetic_codes.o \
likelihood_engine.o \
options.o \
parsimony.o \
parsimony_engine.o \
seq.o \
site_collection.o \
site_pattern.o \
tools.o \
optare/crs.o \
optare/point.o \
optare/newton_1d.o \
optare/golden_section.o \
models/model.o \
models/DNA/DNA_model.o \
models/DNA/DNA_ssm.o \
models/CODON/CODON_model.o \
models/CODON/CODON_modelA.o \
models/CODON/CODON_modelB.o \
models/CODON/CODON_modelC.o \
models/CODON/CODON_modelD.o \
models/CODON/CODON_M0.o \
models/CODON/CODON_M1.o \
models/CODON/CODON_M2.o \
models/CODON/CODON_M3.o \
models/CODON/CODON_M0gtr.o \
models/CODON/CODON_FEBC1.o \
models/CODON/CODON_FEBC1b.o \
models/CODON/FESC/CODON_FESC1.o \
models/CODON/CODON_nh/CODON_M0nh1.0 \
models/CODON/CODON_nh/CODON_M1nh1.0 \
models/CODON/CODON_nh/CODON_M1nh1.0 \
models/CODON/CODON_nh/CODON_M3nh1.0 \
models/CODON/CODON_nh/CODON_M0nh2.0 \
models/CODON/CODON_nh/CODON_MmodelAnh2.0 \
matrices/matrix.o \
matrices/DNA_matrix.o \
matrices/CODON_matrix.o \
matrices/AA_matrix.o \
matrices/int_matrix.o \
matrices/str_matrix.o \
matrices/eigen.o \
incidere/slice_sampler.o \
dendrology/forestry.o \
dendrology/node.o \
dendrology/DNA_node.o \
dendrology/tree.o \
alphabetia/alphabet.o \
alphabetia/DNA_alphabet.o \
alphabetia/CODON_alphabet.o \
alphabetia/AA_alphabet.o

CC = g++

INC=-I/home/jrm/tmp/proteus_beta

.C.o:
 $(CC) $< -c $(INC)

$(PROG): $(OBJS)
 $(CC) -o $@ $(OBJS) -lm

The makefile is included below. It's just a long list of object files and two targets. The problem seems to be that the $(INC) is being ignored for the first target. For example, the output starts with "g++ -c -o main.o main.cpp" instead of "g++ -I/usr/home/jrm/tmp/proteus_beta -c -o main.o main.cpp".

TIA

PROG = proteus

# list of object files
OBJS = main.o \
dataset.o \
genetic_codes.o \
likelihood_engine.o \
options.o \
parsimony.o \
parsimony_engine.o \
seq.o \
site_collection.o \
site_pattern.o \
tools.o \
optare/crs.o \
optare/point.o \
optare/newton_1d.o \
optare/golden_section.o \
models/model.o \
models/DNA/DNA_model.o \
models/DNA/DNA_ssm.o \
models/CODON/CODON_model.o \
models/CODON/CODON_modelA.o \
models/CODON/CODON_modelB.o \
models/CODON/CODON_modelC.o \
models/CODON/CODON_modelD.o \
models/CODON/CODON_M0.o \
models/CODON/CODON_M1.o \
models/CODON/CODON_M2.o \
models/CODON/CODON_M3.o \
models/CODON/CODON_M0gtr.o \
models/CODON/CODON_FEBC1.o \
models/CODON/CODON_FEBC1b.o \
models/CODON/FESC/CODON_FESC1.o \
models/CODON/CODON_nh/CODON_M0nh1.0 \
models/CODON/CODON_nh/CODON_M1nh1.0 \
models/CODON/CODON_nh/CODON_M1nh1.0 \
models/CODON/CODON_nh/CODON_M3nh1.0 \
models/CODON/CODON_nh/CODON_M0nh2.0 \
models/CODON/CODON_nh/CODON_MmodelAnh2.0 \
matrices/matrix.o \
matrices/DNA_matrix.o \
matrices/CODON_matrix.o \
matrices/AA_matrix.o \
matrices/int_matrix.o \
matrices/str_matrix.o \
matrices/eigen.o \
incidere/slice_sampler.o \
dendrology/forestry.o \
dendrology/node.o \
dendrology/DNA_node.o \
dendrology/tree.o \
alphabetia/alphabet.o \
alphabetia/DNA_alphabet.o \
alphabetia/CODON_alphabet.o \
alphabetia/AA_alphabet.o

CC = g++

INC=-I/home/jrm/tmp/proteus_beta

.C.o:
 $(CC) 
lt; -c $(INC)

$(PROG): $(OBJS)
 $(CC) -o $@ $(OBJS) -lm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

是你 2024-10-19 19:12:43

根据您的帖子,您有一个名为 main.cpp 的文件,而不是名为 main.C 的文件。但是您提供了将 .C 文件转换为 .o 的隐式规则。 Make 将使用其内置规则将 main.cpp 编译为 .cpp.o 编译。您有两种选择来执行您想要的操作:

(1) 将隐式规则更改为 .cpp.o (并考虑使用新式规则,即 %.cpp: %.o< /code>)

(2) 声明一个 CXXFLAGS 变量(自动包含在 Make 的 C++ 编译隐式规则中),如下所示:

CXXFLAGS = $(INC)

然后删除您的 .Co 隐式规则。

第二个选项将简化您的 makefile,并且它将与 C++ 文件一起使用,无论扩展名如何。

According to your post, you have a file named main.cpp, not a file named main.C. But you provide an implicit rule for converting .C files to .o. Make will compile main.cpp using its built-in rule for .cpp to .o compilation. You have two options to do what you want:

(1) Change your implicit rule to .cpp.o (and consider using new-style rules, i.e. %.cpp: %.o)

(2) Declare a CXXFLAGS variable (which is automatically included in Make's C++ compilation implicit rule) such as the following:

CXXFLAGS = $(INC)

and then remove your .C.o implicit rule.

The second option will simplify your makefile, and it will work with C++ files, regardless of the extension.

烦人精 2024-10-19 19:12:43

您的源文件以 .C.cpp 结尾吗?

.Co 的编译规则在规则的其他部分之后列出 $(INC),而不是您期望输出出现的位置:

CC  = g++
INC = -I/home/jrm/tmp/proteus_beta

.C.o:
    $(CC) 
lt; -c $(INC)

您应该看到:

g++ file.C -c -I/home/jrm/tmp/proteus_beta

但它似乎完全无视你的规则。你提到了main.cpp;永远不会按照您的规则进行编译。

那么,.C 是可识别的后缀吗?您的源文件是 .C 文件吗?您是否在不区分大小写的文件系统上运行?为什么要设置 C 编译器 (CC)——您的源代码可能存在大小写问题。

Do your source files end with .C or .cpp?

The compilation rule for .C.o lists $(INC) after the other parts of the rule, not where you expect the output to come:

CC  = g++
INC = -I/home/jrm/tmp/proteus_beta

.C.o:
    $(CC) 
lt; -c $(INC)

You should see:

g++ file.C -c -I/home/jrm/tmp/proteus_beta

But it appears to be ignoring your rule altogether. You mention main.cpp; that will never be compiled by your rule.

So, is .C a recognized suffix? Are your source files .C files? Are you running on a case-insensitive file-system? Why are you setting the C compiler (CC) -- you've probably got case problems with your source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文