gpt4 book ai didi

c - Windows 生成文件 : generate debug information

转载 作者:太空宇宙 更新时间:2023-11-04 04:43:18 42 4
gpt4 key购买 nike

我必须在 Windows 上自动执行几个简单的构建。如果我使用特定目标,我能够生成调试信息。

我的生成文件

 .c.obj:
@echo executing compile rule
$(cc) $(cdebug) $(cflags) $(cvars) $*.c

.obj.exe:
@echo executing linker rule
$(link) $(ldebug) $(conflags) -out:$@ $** $(conlibs)

foo.exe: foo.obj
@echo executing target rule
$(link) $(ldebug) $(conflags) -out:$@ $** $(conlibs)

nmake/f Makefile.win foo.exe : make 输出:

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

executing compile rule
cl -Zi -Od -DDEBUG -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_X
86_=1 -DWIN32 -D_WIN32 -W3 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x050
00000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_MT -MTd foo.c
foo.c
executing target rule
link /DEBUG /DEBUGTYPE:cv /INCREMENTAL:NO /NOLOGO -subsystem:console,5.
0 -out:foo.exe foo.obj kernel32.lib ws2_32.lib mswsock.lib advapi32.lib

nmake/f Makefile.win bar.exe : make 输出:

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

cl bar.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

bar.c
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

/out:bar.exe
bar.obj

请注意,没有任何后缀规则被第二次执行。我究竟做错了什么?我在顶部添加了 .SUFFIXES: .exe .obj

最佳答案

首先确保.obj.exe 都在后缀列表中,否则这些后缀规则将不会生效:

.SUFFIXES: .obj .exe

其次,使用$** 很奇怪。为什么要将 foo* 添加到您的链接行?我想你会想要类似 $^ 的东西。

除此之外,我只能建议您检查 make 在两种情况下打印的实际链接器行,并找出它们之间的区别。你不在这里显示。

关于c - Windows 生成文件 : generate debug information,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23801119/

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