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

相关推荐
liu****8 分钟前
2.c++面向对象(三)
开发语言·c++
linux kernel10 分钟前
第二十四讲:C++中的IO流
开发语言·c++
小瓶盖_tl2 小时前
在Mac上安装CocoaPods问题处理
macos·xcode·cocoapods
tt5555555555552 小时前
CSDN 教程:C++ 经典字符串与栈算法题逐行详解
c++·算法·哈希算法
Eiceblue2 小时前
Python OCR 技术实践:从图片中提取文本和坐标
开发语言·python·ocr·visual studio code
周杰伦fans2 小时前
C++ 中的 `::` 全局作用域符
开发语言·c++
bkspiderx3 小时前
C++设计模式之行为型模式:状态模式(State)
c++·设计模式·状态模式
游戏开发爱好者83 小时前
苹果iOS26系统升级:液态玻璃与智能功能全解析
macos·ios·小程序·uni-app·objective-c·cocoa·iphone
会开花的二叉树3 小时前
分布式文件存储 RPC 服务实现
c++·分布式·网络协议·rpc
老侯(Old monkey)4 小时前
C语言:冒泡法排序
c语言·函数调用·指针·冒泡法排序