Mac更新完系统出现两步报错及解决方法

Mac更新完系统,通过命令行准备编译C++文件时,报错:

bash 复制代码
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

解决方法:更新xcode,在命令行运行

bash 复制代码
xcode-select --install

安装完,重新编译,报错:

bash 复制代码
CMake Error at /opt/homebrew/Cellar/cmake/3.25.0/share/cmake/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/caishuxian/GCNO/build/CMakeFiles/CMakeScratch/TryCompile-76ti7x
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_39711/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_39711.dir/build.make CMakeFiles/cmTC_39711.dir/build
    Building C object CMakeFiles/cmTC_39711.dir/testCCompiler.c.o
    /Library/Developer/CommandLineTools/usr/bin/cc   -arch arm64 -MD -MT CMakeFiles/cmTC_39711.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_39711.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_39711.dir/testCCompiler.c.o -c /Users/caishuxian/GCNO/build/CMakeFiles/CMakeScratch/TryCompile-76ti7x/testCCompiler.c
    Linking C executable cmTC_39711
    /opt/homebrew/Cellar/cmake/3.25.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_39711.dir/link.txt --verbose=1
    /Library/Developer/CommandLineTools/usr/bin/cc  -arch arm64 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_39711.dir/testCCompiler.c.o -o cmTC_39711 
    ld: library 'System' not found
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_39711] Error 1
    make: *** [cmTC_39711/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

解决方法:删除原有 build 文件夹,重新创建新 build 文件夹。

相关推荐
Humbunklung33 分钟前
unordered_map使用MFC的CString作为键值遇到C2056和C2064错误
c++·stl·mfc
钟念1 小时前
【打包app】uniapp打包ios端和安卓端app
macos·objective-c·cocoa
小莞尔2 小时前
【51单片机】【protues仿真】基于51单片机数控直流稳压电源系统
c语言·stm32·单片机·嵌入式硬件·51单片机
小莞尔2 小时前
【51单片机】【protues仿真】基于51单片机密码锁系统
c语言·stm32·单片机·嵌入式硬件·51单片机
爱编程的化学家2 小时前
代码随想录算法训练营第十一天--二叉树2 || 226.翻转二叉树 / 101.对称二叉树 / 104.二叉树的最大深度 / 111.二叉树的最小深度
数据结构·c++·算法·leetcode·二叉树·代码随想录
用户6120414922132 小时前
C语言做的停车场管理系统
c语言·后端·敏捷开发
眠りたいです2 小时前
基于脚手架微服务的视频点播系统-数据管理与网络通信部分的预备工作
c++·qt·ui·微服务·云原生·架构·媒体
烦躁的大鼻嘎3 小时前
【Linux】深入Linux多线程架构与高性能编程
linux·运维·服务器·开发语言·c++·ubuntu
野生的编程萌新3 小时前
【C++深学日志】C++编程利器:缺省参数、函数重载、引用详解
c语言·开发语言·c++
愚润求学3 小时前
【贪心算法】day10
c++·算法·leetcode·贪心算法