g++编译出现找不到库,使用pkg-config

g++编译出现找不到库,使用pkg-config

sudo apt-get install pkg-config
g++ main.cpp -o main 'pkg-config --cflags --libs opencv'

g++ $(pkg-config --libs --cflags opencv) ShowImage.cpp -o ShowImage

g++ `pkg-config opencv --cflags` opencv.cpp  -o opencv `pkg-config opencv --libs` 

#安装opencv
tar -xzvf opencv-3.3.0.tar.gz
cd opencv-3.3.0/
cd ..
mkdir my_build_dir
cd my_build_dir
cmake ../opencv-3.3.0 -DWITH_GTK_2_X=ON -DCMAKE_INSTALL_PREFIX=/usr/local
make    # make -j4表示开4个线程来进行编译
make install

常见问题:https://blog.csdn.net/cv_you/article/details/77341631
OpenCV编译遇到的一个常见错误-./bin: error while loading shared libraries: libopencv_highgui.so.3.2: cannot open

你可能感兴趣的:(g++编译出现找不到库,使用pkg-config)