其他分享
首页 > 其他分享> > Cmake构建编译报错查询

Cmake构建编译报错查询

作者:互联网

1 在MAC环境构建Xcode工程:

cmake -B build ****  -G Xcode

2报错

   CMake Error at CMakeLists.txt:2 (project):

   No CMAKE_CXX_COMPILER could be found.

3查看错误日志

在第2步报错后,我们先去找Cmake的错误日志:一般在CmakeFiles文件夹下会有这个文件:CMakeError.log

打开看看:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

检查下命令行工具是否有安装:

 

xcode-select --install 
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

 

 百度一下:

https://www.cnblogs.com/huangfuql1314/p/8417597.html

 

 

 

 

终端输入:sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

之后在去上边第一步操作构建的目录下执行构建命令:

 cmake -B build **【自定义】*  -G Xcode

好了。。。。。。

切换xcode命令行版本

sudo xcode-select --switch /指定版本的xcode路径Xcode.app 



恢复默认的xcode命令行版本 当使用xcodebuild莫名其妙的出问题时,可以考虑使用此命令恢复 sudo xcode-select -r

使用对话框安装命令行工具

sudo xcode-select --install
————————————————

原文链接:https://blog.csdn.net/holdsky/article/details/103066213

 

   

标签:xcodebuild,Cmake,--,xcode,编译,报错,flags,Xcode,select
来源: https://www.cnblogs.com/8335IT/p/16636818.html