【问题标题】:D9024 make unrecognized source file typeD9024 使源文件类型无法识别
【发布时间】:2013-06-05 10:22:25
【问题描述】:

如果我使用 MS cl 在 cmd 行上运行此 cmd:

cl -c /W3 /Od ioapi.c

目标文件ioapi.obj按预期创建。

但是,如果我使用此条目创建一个 makefile:

ioapi.obj: ioapi.c
    cl -c /W3 /Od ioapi.c

上面的cl前面有个tab

然后运行 ​​make ioapi.obj 然后我得到这个错误:

make ioapi.obj
cl -c /W3 /Od ioapi.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/W3', object file assumed
cl : Command line warning D9027 : source file 'C:/MinGW/msys/1.0/W3' ignored
cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/Od', object file assumed
cl : Command line warning D9027 : source file 'C:/MinGW/msys/1.0/Od' ignored

ioapi.c

cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/W3', object file assumed

cl 是 MS VS 2008 编译器。

我已经安装了minGW,版本是6个月前的。

如果我运行 make -n ioapi.c 我会按预期得到这个报告:

cl -c /W3 /Od ioapi.c

我正在从 Visual Studio 2008 命令提示符运行 cl.exe(其中 VS2008 环境变量是预先设置的)。

为什么会出现这个奇怪的错误以及如何解决?

我确实想知道这是否是 MS 环境的问题。但是即使我在运行之前运行 vcvars32.bat 文件来设置 MS 环境,也没有什么区别。

我注意到如果我使用这个:

ioapi.obj: ioapi.c
    cl -c ioapi.c

然后错误消失。但我确实需要传入编译器开关。

【问题讨论】:

    标签: windows visual-studio makefile mingw


    【解决方案1】:

    问题在于 make 对 /W3 /Od 开关的处理。由于 / 符号,make 似乎认为 /W3 是文件的开头。因此,为了防止这种情况,我将开关更改为使用 - 而不是 /。例如,MS 编译器/链接器可以接受的 -W3 -Od。

    所以需要的makefile中的更改是:

    ioapi.obj: ioapi.c
        cl -c -W3 -Od ioapi.c
    

    【讨论】:

    • 谢谢,这帮助我找到了导致我的 D9024 错误的原因。我正在编辑 .vcxproj 中的 ,但忘记添加“;”在我刚刚添加的路径之一的末尾。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-10
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    相关资源
    最近更新 更多