所以我正在尝试在Windows10上构建一个CMake项目,我已经安装了带有CMake的Visual Studio2019以及所有的C++工具。然而,当我试图在Visual Studio Developer命令提示符或Visual Studio Developer PowerShell中运行cmake -S external\ebpf-verifier -B external\ebpf-verifier\build时,我得到了奇怪的行为。以下是在Developer PowerShell中运行的结果。我在命令行版本中得到了类似的结果。在命令提示符下运行它之间的一个主要区别是,pwd生成/d/ebpf-for-windows作为当前控制器,PS生成D:\ebpf-for-windows。我想这是因为我安装了Devkitpro,这就是为什么我安装了/c/和/d/,但是我甚至没有运行devkitpro版本,所以一定有一些配置或环境变量指向它。任何帮助理顺目录的方法都会很有帮助。
C编译器标识为MSVC 19.28.29915.0 -- CXX编译器标识为MSVC 19.28.29915.0 --检查运行中的C编译器:/c/程序文件(x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe --检查运行中的C编译器:/c/ -S -B (x86)/MicrosoftVisual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe - /opt/devkitpro/msys2/usr/share/cmake-3.17.3/Modules/CMakeTestCCompiler.cmake:60出现损坏的CMake错误(消息):C编译器
"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe"不能编写一个简单的测试程序。
它会失败,并显示以下输出:
Change Dir: /d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeTmp
Run Build Command(s):/opt/devkitpro/msys2/usr/bin/make.exe cmTC_42b2b/fast && /opt/devkitpro/msys2/usr/bin/make -f CMakeFiles/cmTC_42b2b.dir/build.make CMakeFiles/cmTC_42b2b.dir/build
make[1]: Entering directory '/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_42b2b.dir/testCCompiler.c.o
"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe" -o CMakeFiles/cmTC_42b2b.dir/testCCompiler.c.o -c /d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeTmp/testCCompiler.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
testCCompiler.c
Linking C executable cmTC_42b2b.exe
/opt/devkitpro/msys2/usr/bin/cmake.exe -E cmake_link_script CMakeFiles/cmTC_42b2b.dir/link.txt --verbose=1
"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe" CMakeFiles/cmTC_42b2b.dir/testCCompiler.c.o -o cmTC_42b2b.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9024 : unrecognized source file type 'CMakeFiles/cmTC_42b2b.dir/testCCompiler.c.o', object file assumed
Microsoft (R) Incremental Linker Version 14.28.29915.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testCCompiler.c.exe
/out:cmTC_42b2b.exe
CMakeFiles/cmTC_42b2b.dir/testCCompiler.c.o
LINK : fatal error LNK1181: cannot open input file 'CMakeFiles\cmTC_42b2b.dir\testCCompiler.c.o'
make[1]: *** [CMakeFiles/cmTC_42b2b.dir/build.make:107: cmTC_42b2b.exe] Error 2
make[1]: Leaving directory '/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:141: cmTC_42b2b/fast] Error 2CMake将无法正确生成此项目。调用栈(最新调用优先):CMakeLists.txt:4 (项目)
--配置不完整,出现错误!另请参阅"/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeOutput.log".另请参阅"/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeError.log".
发布于 2021-05-15 23:44:23
错误消息显示"-o已弃用“,似乎已被忽略,并且编译器正在尝试构建指定的".c.o”文件。删除"-o“和相应的参数,然后重试。
https://stackoverflow.com/questions/67544426
复制相似问题