在 Windows 中构建和添加 Cryto++ 库时遇到问题 [已关闭]

问题描述 投票:0回答:0

我想要在一个小型项目中集成 c++ 的 crypto++ 库。我目前使用 Windows 和 mingw64(本机)作为我的编译器和 cmake 来构建。

我的项目目录如下所示:

Project Root
|-sources
|-lib
   |-crytopp-880 (Contains the CrytoPP library)
   |-cryptopp-cmake (Contains the cmake files for it to work)
|-build
|-CMakeLists.txt

我使用指南通过 Crypto++ CMake 中的 cmake 构建和添加 crypto++。我的根 CMakeLists.txt 看起来像这样。


project(project_cipher)


add_subdirectory(sources build)
add_subdirectory(${PROJECT_SOURCE_DIR}/lib/cryptopp-880)


add_subdirectory(${PROJECT_SOURCE_DIR}/lib/cryptopp-cmake)
set(CRYPTOPP_SOURCES ${PROJECT_SOURCE_DIR}/lib/cryptopp-880)

include_directories(${PROJECT_SOURCE_DIR}/lib/cryptopp-880)
target_link_libraries(cipher cryptopp)

我将其作为 Powershell 命令运行:

cmake -G "MinGW Makefiles" .

输出是:

-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/mingw64/bin/gcc.exe
=> Project : cryptopp-cmake v8.8.0
-- Setting build type to 'Release' as none was specified.
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.41.0.windows.1") 
-- Crypto++ auto fetched at: E:/Programms/CODING PROJECTS/C++ Cypher Project/lib/cryptopp-cmake/cryptopp
fatal: not a git repository (or any of the parent directories): .git
CMake Error at lib/cryptopp-cmake/CMakeLists.txt:221 (string):
  string sub-command STRIP requires two arguments.


-- Using branch  for tests
-- Adding unit test: CMakeFiles
-- Adding unit test: disable-feature
-- Adding unit test: include-prefix
-- Adding unit test: no-install
-- Adding unit test: standard-cpm
-- Adding install integration test: int-install-default
-- Adding install integration test: int-install-prefix
=> Module : cryptopp
CMake Error at lib/cryptopp-cmake/CMakeLists.txt:241 (add_subdirectory):
  The source directory

    E:/Programms/CODING PROJECTS/C++ Cypher Project/lib/cryptopp-cmake/cryptopp

  does not contain a CMakeLists.txt file.


-- Configuring incomplete, errors occurred!

正如它所说,该文件夹缺少 CMakeLists.txt。所以,我添加了一个空白的。然后在运行相同的命令时,它显示:

=> Project : cryptopp-cmake v8.8.0
-- Crypto++ auto fetched at: E:/Programms/CODING PROJECTS/C++ Cypher Project/lib/cryptopp-cmake/cryptopp
fatal: not a git repository (or any of the parent directories): .git
CMake Error at lib/cryptopp-cmake/CMakeLists.txt:221 (string):
  string sub-command STRIP requires two arguments.


-- Using branch  for tests
-- Adding unit test: CMakeFiles
-- Adding unit test: disable-feature
-- Adding unit test: include-prefix
-- Adding unit test: no-install
-- Adding unit test: standard-cpm
-- Adding install integration test: int-install-default
-- Adding install integration test: int-install-prefix
=> Module : cryptopp
-- Configuring incomplete, errors occurred!

我想静态且完全离线地添加库,并使用 readme.md 中给出的指南。然而,它仍然使用在线 git repo 来下载库。

如何以使用下载版本的方式进行设置,并在按预期构建后链接它? (回购协议是这么说的)

c++ cmake mingw mingw-w64 crypto++
© www.soinside.com 2019 - 2024. All rights reserved.