[已解决] The C++ compiler "/usr/local/bin/c++" is not able to compile a simple test program.

问题描述

The CXX compiler identification is unknown
-- The C compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
  The C++ compiler "/usr/local/bin/c++" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp

  

  Run Build Command:"/usr/bin/make" "cmTC_77ead/fast"

  /usr/bin/make -f CMakeFiles/cmTC_77ead.dir/build.make
  CMakeFiles/cmTC_77ead.dir/build

  make[1]: Entering directory
  '/home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp'

  Building CXX object CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o

  /usr/local/bin/c++ -o CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o -c
  /home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  c++: error trying to exec 'cc1plus': execvp: Not a directory

  CMakeFiles/cmTC_77ead.dir/build.make:65: recipe for target
  'CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o' failed

  make[1]: *** [CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o] Error 1

  make[1]: Leaving directory
  '/home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_77ead/fast' failed

  make: *** [cmTC_77ead/fast] Error 2

  

  

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


-- Configuring incomplete, errors occurred!

在编译时指定c++位置,即可解决,cmake时,加上下面的即可

cmake -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/c++ .

或者改为

cmake -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_C_COMPILER=$(which gcc) .
解析以下错误:CMake Error at /Users/fym/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/232.8453.115/CLion 2023.2 EAP.app/Contents/bin/cmake/mac/share/cmake-3.26/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler "/usr/local/bin/g++-13" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/fym/Desktop/C++/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-HWLOEj Run Build Command(s):/Users/fym/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/232.8453.115/CLion 2023.2 EAP.app/Contents/bin/ninja/mac/ninja -v cmTC_1dd3b && [1/2] /usr/local/bin/g++-13 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -fdiagnostics-color=always -o CMakeFiles/cmTC_1dd3b.dir/testCXXCompiler.cxx.o -c /Users/fym/Desktop/C++/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-HWLOEj/testCXXCompiler.cxx [2/2] : && /usr/local/bin/g++-13 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_1dd3b.dir/testCXXCompiler.cxx.o -o cmTC_1dd3b && : FAILED: cmTC_1dd3b : && /usr/local/bin/g++-13 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_1dd3b.dir/testCXXCompiler.cxx.o -o cmTC_1dd3b && : ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libSystem.tbd' for architecture x86_64 collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project) -- Configuring incomplete, errors occurred! [无法重新加载]
07-10
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值