从 NGC 里面下了一个容器,想在里面加个 opencv,cmake 的时候遇到问题:

root@ff2ae4aa882a:~/hive/repository/opencv/opencv-4.5.0/build# cmake ..
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:109 (enable_language):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

很明显,这是没有找到 c++的编译器,查了一下,还真没有 c++或者 g++,果断安装相应的包。

root@ff2ae4aa882a:~/hive/repository/opencv/opencv-4.5.0/build# apt install build-essential

再看一下:

root@ff2ae4aa882a:~/hive/repository/opencv/opencv-4.5.0/build# which c++
/usr/bin/c++
root@ff2ae4aa882a:~/hive/repository/opencv/opencv-4.5.0/build# which g++
/usr/bin/g++

有了,再 cmake 一下:

root@ff2ae4aa882a:~/hive/repository/opencv/opencv-4.5.0/build# cmake ..
-- The CXX compiler identification is GNU 7.5.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works

...

ok!

Logo

一站式 AI 云服务平台

更多推荐