美文网首页
cmake -G Xcode .. No CMAKE_C_CO

cmake -G Xcode .. No CMAKE_C_CO

作者: 蛋Dan | 来源:发表于2021-10-11 11:03 被阅读0次

    使用cmake生成xcode的项目, 报错

    ➜  build git:(master) cmake -G Xcode ..
    -- The C compiler identification is AppleClang 13.0.0.13000029
    -- The CXX compiler identification is AppleClang 13.0.0.13000029
    CMake Error at CMakeLists.txt:37 (project):
      No CMAKE_C_COMPILER could be found.
    
    
    
    CMake Error at CMakeLists.txt:37 (project):
      No CMAKE_CXX_COMPILER could be found.
    

    找不到 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER

    解决办法:

    用xcrun -find c++ 找CMAKE_CXX_COMPILER:

    ➜  build git:(master) xcrun -find c++
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
    

    用xcrun -find cc 找CMAKE_C_COMPILER:

    ➜  build git:(master) xcrun -find cc
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
    

    然后执行 cmake -G Xcode .. 时, 指定编译器地址即可

    cmake -G Xcode ..  -D CMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -D CMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
    

    相关文章

      网友评论

          本文标题:cmake -G Xcode .. No CMAKE_C_CO

          本文链接:https://www.haomeiwen.com/subject/gmdloltx.html