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

相关推荐
学涯乐码堂主4 小时前
GESP C++ 四级第一章:再谈函数(上)
c++·青少年编程·gesp·四级·学漄乐码青少年编程培训
微露清风4 小时前
系统性学习C++-第九讲-list类
c++·学习·list
大佬,救命!!!4 小时前
C++多线程同步与互斥
开发语言·c++·学习笔记·多线程·互斥锁·同步与互斥·死锁和避免策略
开开心心就好4 小时前
电子报纸离线保存:一键下载多报PDF工具
网络·笔记·macos·pdf·word·音视频·phpstorm
散峰而望5 小时前
C++入门(一)(算法竞赛)
c语言·开发语言·c++·编辑器·github
C_Liu_5 小时前
13.C++:继承
开发语言·c++
凡同学。6 小时前
通信人C++自学
c++·应届生秋招·后端四件套
威桑6 小时前
C++ Linux 环境下内存泄露检测方式
linux·c++
l1t6 小时前
利用DeepSeek辅助修改luadbi-duckdb读取DuckDB decimal数据类型
c语言·数据库·单元测试·lua·duckdb
报错小能手6 小时前
C++笔记(面向对象)RTTI操作符
开发语言·c++·笔记