使用 CMake (Linux Mint) 编译时如何修复“CXX 编译器没有已知功能”

SDL*_*DLC 9 c++ cmake linux-mint

我正在尝试安装此插件:https ://github.com/CatxFish/obs-v4l2sink

\n\n

我遵循了所有步骤(安装了 QT,获取了 obs-studio 源代码,然后尝试构建插件):

\n\n
sudo apt install qtbase5-dev\n\ngit clone --recursive https://github.com/obsproject/obs-studio.git\n\ngit clone https://github.com/CatxFish/obs-v4l2sink.git\ncd obs-v4l2sink\nmkdir build && cd build\ncmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是之后...

\n\n
 -- Configuring done\nCMake Error in CMakeLists.txt:\n  No known features for CXX compiler\n\n  ""\n\n  version .\n\n\n-- Build files have been written to: /home/********/obs-v4l2sink/build\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我第一次使用cmake(而不是make)进行编译,我对编译不太了解。cmake在安装和尝试编译插件之间我是否错过了任何步骤?

\n\n

根据我在网上找到的信息,这就是我所做的:

\n\n
    \n
  • build-essential已经安装;
  • \n
  • c++cc并且全部都已安装;
  • \n
  • 尝试添加-DCMAKE_CXX_COMPILER=/usr/bin/cccmake命令行(与 c++ 相同);
  • \n
\n\n

当然,我已经完成了update && upgrade

\n\n

以下是 CMakeError.log 文件中的内容:

\n\n
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.\nCompiler: /usr/bin/cc \nBuild flags: \nId flags:  \n\nThe output was:\n1\n/usr/bin/ld\xc2\xa0: ne peut pas trouver Scrt1.o\xc2\xa0: Aucun fichier ou dossier de ce type\n/usr/bin/ld\xc2\xa0: ne peut pas trouver crti.o\xc2\xa0: Aucun fichier ou dossier de ce type\ncollect2: error: ld returned 1 exit status\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nDetermining if the C compiler works failed with the following output:\nChange Dir: /home/***********/obs-v4l2sink/build/CMakeFiles/CMakeTmp\n\nRun Build Command:"/usr/bin/make" "cmTC_f18b2/fast"\n/usr/bin/make -f CMakeFiles/cmTC_f18b2.dir/build.make CMakeFiles/cmTC_f18b2.dir/build\nmake[1]\xc2\xa0: on entre dans le r\xc3\xa9pertoire \xc2\xab\xc2\xa0/home/***********/obs-v4l2sink/build/CMakeFiles/CMakeTmp\xc2\xa0\xc2\xbb\nBuilding C object CMakeFiles/cmTC_f18b2.dir/testCCompiler.c.o\n/usr/bin/cc    -o CMakeFiles/cmTC_f18b2.dir/testCCompiler.c.o   -c /home/***********/obs-v4l2sink/build/CMakeFiles/CMakeTmp/testCCompiler.c\nLinking C executable cmTC_f18b2\n/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f18b2.dir/link.txt --verbose=1\n/usr/bin/cc      CMakeFiles/cmTC_f18b2.dir/testCCompiler.c.o  -o cmTC_f18b2 \n/usr/bin/ld\xc2\xa0: ne peut pas trouver Scrt1.o\xc2\xa0: Aucun fichier ou dossier de ce type\n/usr/bin/ld\xc2\xa0: ne peut pas trouver crti.o\xc2\xa0: Aucun fichier ou dossier de ce type\ncollect2: error: ld returned 1 exit status\nCMakeFiles/cmTC_f18b2.dir/build.make:97: recipe for target \'cmTC_f18b2\' failed\nmake[1]: *** [cmTC_f18b2] Error 1\nmake[1]\xc2\xa0: on quitte le r\xc3\xa9pertoire \xc2\xab\xc2\xa0/home/***********/obs-v4l2sink/build/CMakeFiles/CMakeTmp\xc2\xa0\xc2\xbb\nMakefile:126: recipe for target \'cmTC_f18b2/fast\' failed\nmake: *** [cmTC_f18b2/fast] Error 2\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags:  \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: -c \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --c++ \n\nThe output was:\nNo such file or directory\n\n\nCompiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.\nCompiler: CMAKE_CXX_COMPILER-NOTFOUND \nBuild flags: \nId flags: --ec++ \n\nThe output was:\nNo such file or directory\n\n\nChecking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":\nc++: fatal error: no input files\ncompilation terminated.\nChecking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":\nc++: fatal error: no input files\ncompilation terminated.\n
Run Code Online (Sandbox Code Playgroud)\n

Jin*_*won 11

我正在分享我的问题。

我一应用Quickstart: Building with CMake 就收到了同样的消息。

问题是project指定LANGUAGES元素的命令。

project(my-project C)
Run Code Online (Sandbox Code Playgroud)

我删除了该C部分,现在可以使用了。

project(my-project)
Run Code Online (Sandbox Code Playgroud)

指定两种语言似乎都有效。

project(my-project LANGUAGES C CXX)
Run Code Online (Sandbox Code Playgroud)


squ*_*les 10

将我的评论变成答案:

错误消息很奇特。看起来 CMake 之前检测到了 C++ 编译器,并且正在为其搜索编译器功能。但是,现在它找不到该编译器(空白编译器名称和版本):

CMake Error in CMakeLists.txt:
  No known features for CXX compiler

  ""

  version .
Run Code Online (Sandbox Code Playgroud)

这表明 CMake 配置已过时,清理它可能会很有用。尝试build完全删除该文件夹,然后再次运行教程中的 CMake 步骤(从创建文件夹开始,build如下所示)。这将有助于清除旧的/缓存的 CMake 设置:

mkdir build && cd build
cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install
Run Code Online (Sandbox Code Playgroud)