【问题标题】:/Fe (Name EXE File) is not working/Fe(命名 EXE 文件)不起作用
【发布时间】:2014-10-07 16:22:47
【问题描述】:

我想在 windows 7、visual studio 2010 中使用编译 cpp 源文件

Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64

当我执行以下操作时

>cl /EHs main.cpp -o test

我明白了

cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release

好吧,很公平。我已经检查了这个页面/Fe (Name EXE File)。这个选项对我不起作用。它给了我这个错误

cl : Command line warning D9024 : unrecognized source file type 'test', object file assumed
main.cpp
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj
test
LINK : fatal error LNK1181: cannot open input file 'test.obj' 

现在我应该如何激活这个选项?我总是觉得难以阅读MSDN Library。这根本不友好。

【问题讨论】:

    标签: c++ visual-studio-2010 compiler-construction windows-7 exe


    【解决方案1】:

    注意/Fe 和文件名之间没有空格。

    cl /EHs /Fetest.exe main.cpp
    

    或者,您可以使用冒号语法:

    cl /EHs /Fe: test.exe main.cpp
    

    【讨论】:

    • 不开玩笑。是不是因为它们不应该间隔???????这太奇怪了,绝对奇怪。谢谢它的工作。不过/Fe: 并没有和我一起工作。
    【解决方案2】:

    您可以使用

    实现相同的目标
    cl /Ehs main.cpp /link /OUT:test.exe
    

    /link 告诉 cl 将这些选项传递给链接器,/OUT 指定输出文件的名称。

    【讨论】:

    • 成功了。我不确定,但我觉得使用/link 不好,因为我知道编译器会这样做。是否有理由不使用-o 甚至/o
    • cl 选项中没有-o/o。您不应使用任何已弃用的选项,因为它可能在将来的版本中不起作用。
    猜你喜欢
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多