Visual C++命令行编译器 (CL.EXE) 重定向 OBJ 文件
编译器 (CL.EXE) 可以获取多个源文件,但喜欢在调用它的目录中生成所有 OBJ 文件。我找不到用于设置输出目录的编译器标志,但我确实为单个 OBJ 找到了一个,但它不能采用多个源。
无需指定每个文件来重定向输出,并且无需为 NMAKE 提供大量目标,是否有一种简单的方法可以通过 CL 来完成此操作?
The compiler (CL.EXE) can take multiple source files, but likes to generate all the OBJ files in the directory that it is invoked. I couldn't find the compiler flag to set an output directory but I did find one for an individual OBJ, but it can't take multiple sources.
Without having to specify each file to redirect the output and having lots of targets for NMAKE, is there an easy way to do it through CL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明
/Fo
选项确实有效,但您指定的目录必须以反斜杠结尾。因此可以工作,但 cl /Fo.\obj -c ... 会失败。
It turns out the
/Fo
option actually works, but the directory you specify must end with a backslash. ThusWorks but
cl /Fo.\obj -c ...
would fail.只是为了添加唯一的答案。如果引用 obj 路径,则必须在路径结束引号之后添加尾部反斜杠,或者如果在引号之前添加则将其转义。
OR
OR
说到
NMAKE
,在NMAKE
上传递带引号的宏值时需要类似的语法命令行。结尾的反斜杠似乎是需要注意的关键部分。
OR
OR
NOT
,因为这会导致转义引号
\"
并会抓取命令行上后面的任何内容并将其放入$(SOMEDIR)
中。花了我一段时间诊断这种行为,希望这可以节省其他人的时间。Just to add to the only answer. In case when the obj path is quoted, the trailing backslash has to be either added after the path closing quote, or escaped if added before the quote.
OR
OR
Speaking of
NMAKE
, similar syntax is expected when passing quoted macro values onNMAKE
command line. The trailing backslash seems to be the crucial bit to watch for.
OR
OR
NOT
as this would result in an escaped quote
\"
and would grab whatever else followed on the command line and put it into$(SOMEDIR)
. Took me a while to diagnose such a behavior, hope this would save time to someone else.