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

相关推荐
郝学胜-神的一滴5 分钟前
二叉树与递归:解锁高级数据结构的编程内功心法
开发语言·数据结构·c++·算法·面试
潇湘散客9 分钟前
CAX软件插件化设计实战:从框架到3D基础功能落地
c++·图形学·opengl
大袁同学9 分钟前
【线程】:在并发的荒原上构筑秩序
linux·c++·线程
2501_9160074711 分钟前
XCode 15 IDE新特性:苹果集成开发环境全面升级,提升编程效率与体验
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
无限进步_12 分钟前
【C++】深入右值引用:移动语义与完美转发
java·开发语言·c++
csdn_aspnet19 分钟前
C++ (Naive Partition Algorithm)朴素划分算法
数据结构·c++·算法
c++之路25 分钟前
单例模式(Singleton Pattern)
开发语言·c++·单例模式
c++之路31 分钟前
代理模式(Proxy Pattern)
开发语言·c++·代理模式
handler0138 分钟前
速通蓝桥杯省一: 前缀和&差分(附经典例题)
c语言·c++·笔记·职场和发展·蓝桥杯
谙弆悕博士38 分钟前
快速学C语言——第 11 章:指针与数组
服务器·c语言·开发语言·学习方法·业界资讯·指针·数组