【发布时间】:2025-11-23 20:20:07
【问题描述】:
正如标题所说。我正在尝试编译找到on Google's Github 的代码。我对 CMake 了解不多。首先,我按照说明运行以下命令:
git submodule update --init --recursive
我收到以下错误消息:fatal: not a git repository (or any of the parent directories): .git。之后我尝试运行以下构建命令:
cmake -DCRC32C_BUILD_TESTS=0 -DCRC32C_BUILD_BENCHMARKS=0 .. && make all install
输出如下图:
l install
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.22.27905.0
-- The CXX compiler identification is MSVC 19.22.27905.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Performing Test CRC32C_HAVE_NO_DEPRECATED
-- Performing Test CRC32C_HAVE_NO_DEPRECATED - Failed
-- Performing Test CRC32C_HAVE_NO_SIGN_COMPARE
-- Performing Test CRC32C_HAVE_NO_SIGN_COMPARE - Failed
-- Performing Test CRC32C_HAVE_NO_UNUSED_PARAMETER
-- Performing Test CRC32C_HAVE_NO_UNUSED_PARAMETER - Failed
-- Performing Test CRC32C_HAVE_NO_MISSING_FIELD_INITIALIZERS
-- Performing Test CRC32C_HAVE_NO_MISSING_FIELD_INITIALIZERS - Failed
-- Performing Test HAVE_BUILTIN_PREFETCH
-- Performing Test HAVE_BUILTIN_PREFETCH - Failed
-- Performing Test HAVE_MM_PREFETCH
-- Performing Test HAVE_MM_PREFETCH - Success
-- Performing Test HAVE_SSE42
-- Performing Test HAVE_SSE42 - Success
-- Performing Test HAVE_ARM64_CRC32C
-- Performing Test HAVE_ARM64_CRC32C - Failed
-- Performing Test HAVE_STRONG_GETAUXVAL
-- Performing Test HAVE_STRONG_GETAUXVAL - Failed
-- Performing Test HAVE_WEAK_GETAUXVAL
-- Performing Test HAVE_WEAK_GETAUXVAL - Failed
CMake Error at CMakeLists.txt:184 (add_subdirectory):
The source directory
C:/Source/crc32c-master/third_party/glog
does not contain a CMakeLists.txt file.
-- Configuring incomplete, errors occurred!
See also "C:/Source/crc32c-master/build/CMakeFiles/CMakeOutput.log".
See also "C:/Source/crc32c-master/build/CMakeFiles/CMakeError.log".
我查看了错误日志,但没有得到太多帮助。 third_party/glog 目录是空的,所以没有任何应该有的CMakeLists.txt 文件。 (/third_party 下的 /benchmark 和 /googletest 子目录也是空的。?)
有人使用 Visual Studio 成功构建过这个吗?如果有,怎么做?
我认为这并不重要,但我使用的是 VS2019 Community Edition 16.2.5 和 CMake 3.15.2。 TIA。
【问题讨论】:
-
您是克隆代码还是下载代码?看起来你下载了它,你需要克隆它才能让子模块工作
-
@AlanBirtles 非常感谢。是的,我没有克隆代码,因为我对git一无所知,所以我不知道该怎么做。我尝试了
git https://github.com/google/crc32c.git,但得到了error: cannot spawn git-https://github.com/google/crc32c.git: Invalid argument。所以我不知道。 -
@AlanBirtles 我说得太早了。再看看 GitHub,我能够执行
git clone命令。然后子模块似乎工作,所以我再次尝试 CMake 构建命令。它已经进一步发展,所以我会看看最终结果是什么。再次感谢。 -
@AlanBirtles 成功了。我收到了错误
'make' is not recognized as an internal or external command, operable program or batch file.但它确实创建了 .sln 解决方案文件,所以我能够在 VS 中将它调出并编译好。谢谢!如果您想要积分,您可以将其发布为答案,我会标记它。
标签: c++ visual-studio-code crc