【问题标题】:The C compiler is not able to compile a simple test programC 编译器无法编译简单的测试程序
【发布时间】:2019-03-24 21:22:04
【问题描述】:

我正在尝试从 GitHub 构建一个项目,即这个项目 https://github.com/notAlaanor/cpp-type-highlighter(它只是另一个人的回购)。

但在尝试编译后我得到一个错误,例如:

-- The C compiler identification is MSVC 19.20.27404.0
-- The CXX compiler identification is MSVC 19.20.27404.0
-- Check for working C compiler: E:/VS19/VC/Tools/MSVC/14.20.27404/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: E:/VS19/VC/Tools/MSVC/14.20.27404/bin/Hostx86/x86/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):

The C compiler

        "E:/VS19/VC/Tools/MSVC/14.20.27404/bin/Hostx86/x86/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

    Change Dir: C:/Users/theha/cpp-type-highlighter/build/CMakeFiles/CMakeTmp

    Run Build Command:"nmake" "/nologo" "cmTC_b368f\fast"
        E:\VS19\VC\Tools\MSVC\14.20.27404\bin\HostX64\x64\nmake.exe -f CMakeFiles\cmTC_b368f.dir\build.make /nologo -L                  CMakeFiles\cmTC_b368f.dir\build
    Building C object CMakeFiles/cmTC_b368f.dir/testCCompiler.c.obj
        E:\VS19\VC\Tools\MSVC\14.20.27404\bin\Hostx86\x86\cl.exe @C:\Users\theha\AppData\Local\Temp\nm8555.tmp
    testCCompiler.c
    Linking C executable cmTC_b368f.exe
        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_b368f.dir --manifests  -- E:\MinGW\bin\ld.exe /nologo @CMakeFiles\cmTC_b368f.dir\objects1.rsp @C:\Users\theha\AppData\Local\Temp\nm85C3.tmp
    LINK Pass 1: command "E:\MinGW\bin\ld.exe /nologo @CMakeFiles\cmTC_b368f.dir\objects1.rsp /out:cmTC_b368f.exe /implib:cmTC_b368f.lib /pdb:C:\Users\theha\cpp-type-highlighter\build\CMakeFiles\CMakeTmp\cmTC_b368f.pdb /version:0.0 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_b368f.dir/intermediate.manifest CMakeFiles\cmTC_b368f.dir/manifest.res" failed (exit code 1) with the following output:
    E:\MinGW\bin\ld.exe: cannot find /nologo: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /out:cmTC_b368f.exe: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /implib:cmTC_b368f.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /pdb:C:\Users\theha\cpp-type-highlighter\build\CMakeFiles\CMakeTmp\cmTC_b368f.pdb: Invalid argument
    E:\MinGW\bin\ld.exe: cannot find /version:0.0: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /debug: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /INCREMENTAL: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /subsystem:console: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find kernel32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find user32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find gdi32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find winspool.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find shell32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find ole32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find oleaut32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find uuid.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find comdlg32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find advapi32.lib: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /MANIFEST: No such file or directory
    E:\MinGW\bin\ld.exe: cannot find /MANIFESTFILE:CMakeFiles\cmTC_b368f.dir/intermediate.manifest: Invalid argument
    CMakeFiles\cmTC_b368f.dir/manifest.res: file not recognized: file format not recognized
    NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: 'E:\VS19\VC\Tools\MSVC\14.20.27404\bin\HostX64\x64\nmake.exe' : return code '0x2'
    Stop.




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Configuring incomplete, errors occurred!

如果我运行命令 where clang 我会得到一个输出:

C:\Program Files\LLVM\bin\clang.exe

我还运行命令cmake ..vcvarsall.bat,所以,在运行cmake .. 之前,我运行call "E:\VS19\VC\Auxiliary\Build\vcvarsall.bat" amd64。 我在 Windows 10 上构建,我有 Visual Studio 2019 和 MinGW。

如何解决这个问题?

【问题讨论】:

  • 你的测试程序实际上是什么?
  • @πάνταῥεῖ 嗨,我只是尝试从另一个人的 GitHub 构建项目。
  • 您正在混合构建工具 - 使用 Microsoft 的编译器 (cl.exe) 和 MinGW 的链接器,但传递 Microsoft 链接选项。
  • “我有 Visual Studio 2019 和 MinGW。” - 根据日志,Visual Studio 编译器 (cl) 与 MinGW 链接器 (E:\MinGW\bin\ld.exe) 一起使用。他们永远不会一起工作。确保您使用Visual Studio 16 2019 CMake generator
  • @1201ProgramAlarm 嗨,是的,我想是的,但是如何解决这个问题?这不是我的项目,我只是尝试用另一个人来构建它?

标签: c++ build cmake


【解决方案1】:

如果您已下载解决方案,您可能需要重新定位并重新构建解决方案。

右键解决方案 -> 重定向解决方案 -> 选择 relvent/latest SDK。

右键解决方案 -> 重建解决方案。

希望对您有所帮助。

【讨论】:

  • 嗨,我需要在 Visual Studio 中执行此操作吗?那么,我需要在 VS 中将其作为项目打开吗?这不是我的项目,我只是尝试构建它。
  • 不 - 症状会有所不同。
猜你喜欢
  • 2021-01-23
  • 1970-01-01
  • 1970-01-01
  • 2019-09-20
  • 2019-05-07
  • 2020-11-13
  • 2017-05-21
相关资源
最近更新 更多