默认已安装 sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
#管理GCC
- 前提是安装了多个gcc版本,可采取如下命令
sudo apt-get install gcc-11 g++-11
- 然后选择要使用的gcc版本
update-alternatives --config gcc
- 输入你想使用的版本的序号,如1
- 查看当前版本
gcc -v
#管理opencv
- 下载源文件,本文选的是opencv3.4.15
source
版本 - 在任意目录下创建存放opencv安装路径
|
|
- 解压缩opencv-3.4.15.zip文件
|
|
- cmake opencv
|
|
- 编译 && 安装
|
|
没报其他错误的话,OpenCV已经顺利被安装到自定义路径otherpackages/opencv3.4.15中了
- 使用opencv
- 将otherpackages中的opencv3.4.15复制到项目路径
- 在qt.pro中粘贴代码
1 2 3 4 5 6
INCLUDEPATH += ./opencv3415/include \ ./opencv3415/include/opencv \ ./opencv3415/include/opencv2 LIBS += -L./opencv3415/lib -lopencv_core -lopencv_highgui \ -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio \
- 如果是cmake
1 2 3 4 5 6 7 8 9 10 11 12 13
include_directories( ${CMAKE_SOURCE_DIR}/./opencv3415/include ) set(link_libs ${CMAKE_SOURCE_DIR}/./opencv3415/lib/libopencv_core.so ${CMAKE_SOURCE_DIR}/./opencv3415/lib/libopencv_highgui.so ${CMAKE_SOURCE_DIR}/./opencv3415/lib/libopencv_imgcodecs.so ${CMAKE_SOURCE_DIR}/./opencv3415/lib/libopencv_imgproc.so ${CMAKE_SOURCE_DIR}/./opencv3415/lib/libopencv_videoio.so ) add_executable(main ./main.cpp) target_link_libraries(main ${link_libs})
- 将otherpackages中的opencv3.4.15复制到项目路径
#管理cuda
- 删除原软链接
cd /usr/local
sudo unlink cuda
- 建立新链接
sudo ln -snf /usr/local/
cuda-xx
/usr/local/cudacuda-xx是文件夹名
- 查看当前版本
nvcc -V