簡體   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. 但是,當嘗試在 Visual Studio 開發人員命令提示符或 Visual Studio 開發人員 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 版本,所以必須有一些配置或環境變量指向它。 任何有助於理順目錄的幫助都會有所幫助。

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"

無法編譯簡單的測試程序。

它因以下 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 將無法正確生成此項目。 調用堆棧(最近調用優先):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”。

是我正在嘗試開始工作的 GitHub 項目, 這里是設置步驟。

錯誤消息說“-o is deprecated”,似乎被忽略了,編譯器正在嘗試構建指定的“.c.o”文件。 刪除“-o”和相應的參數,然后重試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM