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 文件夹。

相关推荐
重启的码农2 小时前
llama.cpp 分布式推理介绍(7) 远程后端缓冲区 (RPC Buffer)
c++·人工智能·神经网络
Vect__2 小时前
链表漫游指南:C++ 指针操作的艺术与实践
数据结构·c++·链表
saltymilk3 小时前
C++ 使用分治减小模板递归深度
c++
悠哉清闲4 小时前
C ++代码学习笔记(一)
c++·笔记·学习
zhysunny5 小时前
Day22: Python涡轮增压计划:用C扩展榨干最后一丝性能!
c语言·网络·python
YxVoyager5 小时前
【C标准库】详解<stdio.h>标准输入输出库
c语言·c++
希望_睿智5 小时前
实战设计模式之解释器模式
c++·设计模式·架构
海鸥_6 小时前
C++中不加{}导致的BUG
c++·bug
努力努力再努力wz8 小时前
【c++进阶系列】:万字详解多态
java·linux·运维·开发语言·c++
用户47949283569158 小时前
平时都在用,但是你不知道的VS Code黑科技:智能双击选择背后的原理
程序员·visual studio code