如何自定义Microsoft命令行编译器cl的.exe文件名?

7
我从搜索中找到的唯二选项是/OUT和/Fe,但都对我无效:
使用/Fe没有显示错误,但当前目录中也没有找到输出文件:
C:\hands_on\C>cl /Fe:test.exe main.c
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out::test.exe
main.obj

C:\hands_on\C>ls
main.c  main.obj

使用/OUT会出现错误:
C:\hands_on\C>cl /OUT:test.exe main.c
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9025 : overriding '/Ot' with '/Os'
cl : Command line warning D9025 : overriding '/Os' with '/Ot'
cl : Command line warning D9002 : ignoring unknown option '/OU'
cl : Command line warning D9002 : ignoring unknown option '/OT'
cl : Command line warning D9002 : ignoring unknown option '/O:'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
cl : Command line warning D9002 : ignoring unknown option '/O.'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
cl : Command line warning D9002 : ignoring unknown option '/Oe'
main.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj

编译器的版本:
C:\hands_on\C>cl
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

1
有趣的是,我的问题被投了反对票。虽然看起来像是用户错误,但我认为错过这个微不足道的部分的原因之一是命令选项格式的不一致性,也就是说,有时需要在选项和其值之间加上“:”。我对MS环境还很陌生。是否有一份文件可以解释一下一般的命令行选项语法? - Ltf4an
1个回答

10
语法如下:
cl /Fetest.exe main.c

没有空格或标点符号,或者:

cl /Fe: test.exe main.c

带有冒号和空格。

你有一个冒号,但没有空格:

cl /Fe:test.exe main.c


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接