简体   繁体   English

CMake 使用 Visual Studio 在 Windows 10 上构建问题

[英]CMake Build Issues on Windows 10 with Visual Studio

So I'm trying to build a CMake project on Windows 10 I have Visual Studio 2019 installed with CMake and all the C++ tooling as well. So I'm trying to build a CMake project on Windows 10 I have Visual Studio 2019 installed with CMake and all the C++ tooling as well. However I'm getting weird behavior when trying to run cmake -S external\ebpf-verifier -B external\ebpf-verifier\build in either the Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.但是,当尝试在 Visual Studio 开发人员命令提示符或 Visual Studio 开发人员 PowerShell 中运行 cmake -S external\ebpf-verifier -B external\ebpf-verifier\build 时,我遇到了奇怪的行为。 Here is the result from running in the Developer PowerShell.这是在 Developer PowerShell 中运行的结果。 I get a similar result in the Command Line version.我在命令行版本中得到了类似的结果。 The one major difference between running it in Command Prompt is that pwd results in /d/ebpf-for-windows as the current director and PS results in D:\ebpf-for-windows.在命令提示符中运行它的一个主要区别是 pwd 导致 /d/ebpf-for-windows 作为当前导向器,而 PS 导致 D:\ebpf-for-windows。 I think this is because I have Devkitpro installed which is why I have /c/ and /d/ however I'm not even running the devkitpro version so there must be some config or environment variable pointing to it.我认为这是因为我安装了 Devkitpro,这就是为什么我有 /c/ 和 /d/ 但是我什至没有运行 devkitpro 版本,所以必须有一些配置或环境变量指向它。 Any help to get the directories straightened out would be helpful.任何有助于理顺目录的帮助都会有所帮助。

D:\ebpf-for-windows>cmake -S external\ebpf-verifier -B external\ebpf-verifier\build -- The C compiler identification is MSVC 19.28.29915.0 -- The CXX compiler identification is MSVC 19.28.29915.0 -- Check for working C compiler: /c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe -- Check for working C compiler: /c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe - broken CMake Error at /opt/devkitpro/msys2/usr/share/cmake-3.17.3/Modules/CMakeTestCCompiler.cmake:60 (message): The C compiler D:\ebpf-for-windows>cmake -S external\ebpf-verifier -B external\ebpf-verifier\build -- C编译器标识为MSVC 19.28.29915.0 -- CXX编译器标识为MSVC 19.28.29915.0 --检查工作 C 编译器:/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe -- 检查工作 Z0D61F8370CAD1D412F80B84D143E 编译器: /c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe - 在 /opt/devkitpro/msys2/usr/ 处损坏 CMake 错误share/cmake-3.17.3/Modules/CMakeTestCCompiler.cmake:60(消息):C编译器

"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe"

is not able to compile a simple test program.无法编译简单的测试程序。

It fails with the following output:它因以下 output 而失败:

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 2

CMake will not be able to correctly generate this project. CMake 将无法正确生成此项目。 Call Stack (most recent call first): CMakeLists.txt:4 (project)调用堆栈(最近调用优先):CMakeLists.txt:4(项目)

-- Configuring incomplete, errors occurred. -- 配置不完整,出现错误。 See also "/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeOutput.log".另请参阅“/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeOutput.log”。 See also "/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeError.log".另请参阅“/d/ebpf-for-windows/external/ebpf-verifier/build/CMakeFiles/CMakeError.log”。

Here is the GitHub project that I'm trying to get to work and here are the setup steps.是我正在尝试开始工作的 GitHub 项目, 这里是设置步骤。

The error message says "-o is deprecated", appears to be ignored, and the compiler is trying to build the specified ".c.o" file.错误消息说“-o is deprecated”,似乎被忽略了,编译器正在尝试构建指定的“.c.o”文件。 Remove the "-o" and corresponding argument, then try again.删除“-o”和相应的参数,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM