常用软件和库安装

1、openGL安装

    sudo apt-get install build-essential libgl1-mesa-dev
    sudo apt-get install freeglut3-dev
    sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev

 2、cmake安装

sudo apt-get install cmake

3、git安装

sudo apt-get install git

4、opencv 安装

下载地址这里:https://opencv.org/opencv-3-4/

注:opencv4以上的是不默认生成.pc文件的,设置OPENCV_GENERATE_PKGCONFIG=ON后就会生成,其他版本设置了也没事.

依赖安装:

$ 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

opencv编译:

unzip opencv-3.4.0.zip
cd opencv-3.4.0 
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..
//$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON  -D WITH_XINE=ON  -D WITH_OPENGL=ON  -D WITH_TBB=ON  -D BUILD_EXAMPLES=ON  -D BUILD_NEW_PYTHON_SUPPORT=ON  -D WITH_V4L=ON ..
make -j4
sudo make install
配置环境:
$ vim /etc/ld.so.conf.d/opencv.conf
# 在文件中添加‘/usr/local/lib’       #先查看下opencv的共享库路径是在 /usr/local/lib 还是在 /usr/local/lib64 里面
$ sudo ldconfig
$ sudo cp -f /usr/local/lib/pkgconfig/opencv.pc  /usr/lib/pkgconfig/
$ vim /etc/bash.bashrc # 在文件尾添加:‘PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH’  

测试:

g++ `pkg-config --libs --cflags opencv`  file.cc 


posted @ 2019-12-04 16:14  玥茹苟  阅读(259)  评论(0编辑  收藏  举报