ubuntu中使用cmake编译报错No CMAKE_CXX_COMPILER could be found.的解决方法
- No CMAKE_CXX_COMPILER could be found.
- Could NOT find CUDA (missing: CUDA_NVCC_EXECUTABLE CUDA_CUDART_LIBRARY)
- Could not find a package configuration file provided by "OpenCV" with any
No CMAKE_CXX_COMPILER could be found.
ubuntu编译的时候出现以下报错:
CMake Error at CMakeLists.txt:3 (project):No CMAKE_CXX_COMPILER could be found.Tell CMake where to find the compiler by setting either the environmentvariable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full pathto the compiler, or to the compiler name if it is in the PATH.
解决办法如下:
- 确保安装了C++编译器:
- 对于 Windows,你可能需要安装 Visual Studio,并确保选择了 Desktop development with C++ 选项,这样才能安装C++编译器(如 cl.exe)。
- 对于 Linux 和 macOS,你需要安装 g++ 或者 clang:
Ubuntu: 你可以通过以下命令安装:
sudo apt updatesudo apt install build-essential
安装过程
重新编译,成功。报cuda错误
Could NOT find CUDA (missing: CUDA_NVCC_EXECUTABLE CUDA_CUDART_LIBRARY)
- 检查环境变量, ls /usr/local/cuda/bin,如果已安装,运行下面的代码,否则会提示没路径
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
然后运行 source ~/.bashrc 使配置生效。再试运行 nvcc --version。
- 否则安装CUDA开发包
在这里插入代码片
sudo apt-get install nvidia-cuda-toolkit
Could not find a package configuration file provided by “OpenCV” with any
cmake出现以下报错
CMake Warning at CMakeLists.txt:28 (find_package):By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project hasasked CMake to find a package configuration file provided by "OpenCV", butCMake did not find one.Could not find a package configuration file provided by "OpenCV" with anyof the following names:OpenCVConfig.cmakeopencv-config.cmakeAdd the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"provides a separate development package or SDK, be sure it has beeninstalled.
输入这个指令
sudo apt-get install libopencv-dev python3-opencv