【问题标题】:trying to build mbedtls on windows using cmake尝试使用 cmake 在 Windows 上构建 mbedtls
【发布时间】:2021-10-02 22:53:20
【问题描述】:

我正在使用 cmake 来尝试构建 mbedtls。我从 github 获得了 .zip,解压缩,然后我“cd”到 mbedtls 的目录中。

我收到这样的错误,无论我在哪个子目录/目录中,我都无法成功构建它。 cmake 命令: cmake Visual Studio 10 .

CMake Error at CMakeLists.txt:172 (add_library):
  Cannot find source file:

    error.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:172 (add_library):
  No SOURCES given to target: mbedcrypto

这是我所在的目录。所有的子目录/cmake 文件都在那里。我的问题是...如何在 Windows 上构建 mbedtls?

【问题讨论】:

  • then I "cd"ed into the directory of mbedtls. I get errors like these 你只是从cd 到目录中得到这样的错误吗?你肯定在输入cmake something something。请准确显示您输入的内容。请显示完整的cmake 配置输出以及所有消息。
  • 哦,是的,我忘了,@KamilCuk
  • 请阅读this post了解如何调用CMake。您应该绝对不要使用 CMake 进行源内构建。 cmake . 的任何变体总是错误。相反,您应该运行cmake -G "Visual Studio 16 2019" -S . -B build,然后运行cmake --build build --config Release。 (另外,您真的在使用 Visual Studio 10 吗?!升级!!)

标签: cmake mbedtls


【解决方案1】:

获取release,而不是开发分支的快照。

或者,在3.0+开发分支中,根据readme

Mbed TLS 的源代码包括一些由脚本自动生成的文件,其内容仅取决于 Mbed TLS 源,与平台或库配置无关。这些文件不包含在 Mbed TLS 的开发分支中,但生成的文件包含在官方版本中。 (…)

在运行cmake之前,

在 Windows 上,运行 scripts\make_generated_files.bat 以生成所有与配置无关的文件。

这需要perlpython 和 C 编译器。您可能需要将 CC 环境变量设置为 Visual Studio 中 cl.exe 的路径。

【讨论】:

    【解决方案2】:

    这个序列在 Windows 上对我有用:

    D:\>git clone git@github.com:ARMmbed/mbedtls.git
    D:\>cd mbedtls
    D:\mbedtls>scripts\make_generated_files.bat
    ...
    D:\mbedtls>cd ..
    D:\>cmake -G "Visual Studio 16 2019" -S mbedtls -B mbedtls-build
    ...
    D:\>cmake --build mbedtls-build --config Release
    ...
    D:\>cmake --install mbedtls-build --config Release --prefix mbedtls-install
    ...
    

    这里唯一的非标准步骤是scripts\make_generated_files.bat(或Linux 上的/tests/scripts/check-generated-files.sh -u)。有人想知道为什么他们不包含将这些文件构建为 CMake 自定义命令的步骤... /shrug

    【讨论】:

      猜你喜欢
      • 2013-02-25
      • 2023-03-19
      • 2023-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-05
      • 2015-06-12
      • 2018-03-15
      相关资源
      最近更新 更多