2023年clang12编译问题与解决的记录

最近编译clang12以及尝试基于clang开发一个C++的静态代码分析工具,如下是遇到的环境相关的编译问题与解决方案。在此做个记录,同时供可能会遇到同样问题的同学参考

环境说明

注:如下是最终编译成功的环境

clang分支:

branch : apple/stable/20210107

建议:直接下载 apple/stable/20210107分析的zip包, 地址:https://github.com/apple/llvm-project/tree/apple/stable/20210107
在这里插入图片描述
或只checkout该分支

git clone -b apple/stable/20210107 --single-branch https://github.com/apple/llvm-project.git

本地环境

系统:macOS 3.2.1 (22D68)
xcode版本:Version 14.2 (14C18)
cmake版本:3.25.2

问题与解决

问题1:No CMAKE_C_COMPILER could be found.

- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:55 (project):
  No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:55 (project):
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!

可能是之前卸载xcode13再重装xcode14导致相关的环境变量异常?!

解决1:配置 CMAKE_C_COMPILER等参数

首先有xcrun找到cc跟c++的命令的路径,然后cmake生成xcode工程时指定COMPLIER的路径

xcrun -find cc
xcrun -find c++

在这里插入图片描述

问题2:if given arguments:

CMake Error at cmake/modules/CheckCompilerVersion.cmake:56 (if):
  if given arguments:

    "(" "STREQUAL" "MSVC" ")" "AND" "(" "19.24" "VERSION_LESS_EQUAL" ")" "AND" "(" "VERSION_LESS" "19.25" ")"

cmake版本低了,当前的版本是 3.20.5

解决2:升级cmake

brew upgrade cmake

猜你喜欢

转载自blog.csdn.net/SCHOLAR_II/article/details/129397118