error 1:
Unable to open 'raise.c': Unable to read file '/build/glibc-S9d2JN/glibc-2.27/sysdeps/unix/sysv/linux/raise.c' (Error: Unable to resolve non-existing file '/build/glibc-S9d2JN/glibc-2.27/sysdeps/unix/sysv/linux/raise.c').
error 2:
window.cpp:1239: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage
首先卸载opencv,最佳的卸载方式是找到opencv的安装路径,我的路径是 '~/opencv_build/' ,找到build文件夹 '~/opencv_build/opencv/build',这是安装时 make install 的目录,卸载只需要在这个路径下 sudo make uninstall 就可以完美卸载。
(www.stackoverflow.com/questions/9276169/removing-all-installed-opencv-libs)
OpenCV rebuild cmake command: (tested successful)
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D BUILD_TIFF=ON -D WITH_CUDA=OFF -D ENABLE_AVX=OFF -D WITH_OPENGL=ON -D WITH_OPENCL=OFF -D WITH_IPP=OFF -D BUILD_TBB=ON -D WITH_EIGEN=OFF -D WITH_VTK=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules ..
This cmake command is a combination of the solutions in the following 2 links:
https://stackoverflow.com/questions/59126945/how-can-i-solve-unable-to-open-raise-c-errorvscode-linux
https://stackoverflow.com/questions/28776053/opencv-gtk2-x-error
To install OpenCV with custom build options on Linux (Ubuntu 18), please follow this link:
https://linuxize.com/post/how-to-install-opencv-on-ubuntu-18-04/
PS: remember to use
make -j16
to make cmake process times faster. (The number is subject to your CPU core number. Mine is 16 core CPU).
更新: raise.c 的错误可能来自于 cuda GPU: (nvidia-smi)
Unable to determine the device handle for GPU 0000:65:00.0: GPU is lost. Reboot the system to recover this GPU
他们可以同时出现。解决方案:重启