gpt4 book ai didi

nmake - Microsoft nmake : $? 扩展但 $< 不

转载 作者:行者123 更新时间:2023-12-01 22:41:49 24 4
gpt4 key购买 nike

我正在尝试编译一些第三方代码并遇到了一些奇怪的 NMAKE 行为。

Makefile 中的行是

cholmod_aat.o: ../Core/cholmod_aat.c
$(C) -c $(I) $< -Fo$@

产生以下错误:


Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
NMAKE : warning U4006: special macro undefined : '$<'
cl -O2 -nologo -D__MINGW32__ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig -Focholmod_aat.o
cl : Command line error D8003 : missing source filename
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

为什么 nmake 在预先将 cholmod_aat.c 列为依赖项时说 '$<' 是“未定义”?更令人困惑的是,如果我将 $< 替换为 $?在 makefile 中,nmake 扩展了“$?”就好了:


Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
cl -O2 -nologo -D_<em>MINGW32</em>_ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig ../Include/cholmod.h .
./Include/cholmod_blas.h ../Include/cholmod_check.h ../Include/cholmod_cholesky.
h ../Include/cholmod_complexity.h ../Include/cholmod_config.h ../Include/cholmod
_core.h ../Include/cholmod_internal.h ../Include/cholmod_matrixops.h ../Include/
cholmod_modify.h ../Include/cholmod_partition.h ../Include/cholmod_supernodal.h
../Include/cholmod_template.h ../Core/cholmod_aat.c -Focholmod_aat.o

这是怎么回事?

最佳答案

答案在MSDN上:

$< - Dependent file with a later timestamp than the current target. Valid only in commands in inference rules.

它不在“推理规则”中,它在“描述 block ”中,因为这些东西在 NMAKE 中被调用。

--- 编辑: 扩展我原来的答案---

术语有点奇怪,所以在这种情况下,最容易通过示例来说明。我创建了一个包含 2 条规则的 makefile - 一个描述 block (又名目标规则)和一个推理规则。

C:\temp>type makefile.txt
c.txt : a.txt b.txt
@echo $?
@echo %s

.SUFFIXES: .log

.log.txt:
@echo $<

我为虚拟输入创建了空文件 a.txt、b.txt 和 d.log。然后我在 objective-c .txt 和 d.txt 上运行了 makefile:

C:\temp>nmake /f makefile.txt c.txt d.txt

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.

a.txt b.txt
a.txt
d.log

C:\temp>

希望这能说明 $?、%s 和 $< 之间的区别。 MSDN 文档相当简洁,但代码确实如文档所述那样工作。诚实!

关于nmake - Microsoft nmake : $? 扩展但 $< 不,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12009439/

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