安装opencv4.5中出现的一些问题

miao@openlib:~/opencv_python/opencv-4.5.0/build$ cmake -DCMAKE_EXE_LINKER_FLAGS=-lcblas -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=ON
-DCMAKE_INSTALL_PREFIX=/usr/local cmake -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_C_COMPILER=$(which gcc) OPENCV_EXTRA_MODULES_PATH=../opencv_co
ntrib-4.5.0/modules ..  
-- The CXX compiler identification is GNU 7.5.0
-- The C compiler identification is GNU 7.5.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
 The C++ compiler

   "/usr/bin/g++"

 is not able to compile a simple test program.

 It fails with the following output:

   Change Dir: /home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeTmp
    
   Run Build Command:"/usr/bin/make" "cmTC_22291/fast"
   /usr/bin/make -f CMakeFiles/cmTC_22291.dir/build.make CMakeFiles/cmTC_22291.dir/build
   make[1]:
进入目录“/home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeTmp”
   Building CXX object CMakeFiles/cmTC_22291.dir/testCXXCompiler.cxx.o
   /usr/bin/g++    -fPIE   -o CMakeFiles/cmTC_22291.dir/testCXXCompiler.cxx.o -c /home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeTmp
/testCXXCompiler.cxx
   Linking CXX executable cmTC_22291
   /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_22291.dir/link.txt --verbose=1
   /usr/bin/g++     -lcblas  CMakeFiles/cmTC_22291.dir/testCXXCompiler.cxx.o  -o cmTC_22291  
   /usr/bin/ld:
找不到 -lcblas
   collect2: error: ld returned 1 exit status
   CMakeFiles/cmTC_22291.dir/build.make:97: recipe for target 'cmTC_22291' failed
   make[1]: *** [cmTC_22291] Error 1
   make[1]:
离开目录“/home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeTmp”
   Makefile:126: recipe for target 'cmTC_22291/fast' failed
   make: *** [cmTC_22291/fast] Error 2
    

  

 CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
 CMakeLists.txt:109 (enable_language)


-- Configuring incomplete, errors occurred!
See also "/home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/miao/opencv_python/opencv-4.5.0/build/CMakeFiles/CMakeError.log".

没有lcblas这个库

可以定位一下

miao@openlib:~/opencv_python/opencv-4.5.0/build$ locate cblas.so
/usr/lib/x86_64-linux-gnu/libcblas.so.3
/usr/lib/x86_64-linux-gnu/libcblas.so.3.10.3

代该目录连接一下


miao@openlib:/usr/lib/x86_64-linux-gnu$ sudo ln -s libcblas.so.3 libcblas.so

然后cmake 编译

如果定位不到

则可以下载

sudo apt install install libcblas-dev

也可能出现以下问题

miao@openlib:/usr/lib/x86_64-linux-gnu$ sudo apt-get install libcblas-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树        
正在读取状态信息... 完成        
没有可用的软件包 libcblas-dev,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
然而下列软件包会取代它:
 libatlas-base-dev:i386 libatlas-base-dev

E:
软件包 libcblas-dev 没有可安装候选

解决方法:

sudo apt install libatlas-base-dev

sudo apt install libjasper-dev

sudo apt install libqt4-test

参考以下

https://blog.csdn.net/kevindree/article/details/88772691

原文地址:https://www.cnblogs.com/miaorn/p/14218418.html