<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.3.1</li>
<li>Operating System / Platform =&gt; MacOS X EI Capitan 10.11.6</li>
<li>Compiler =&gt; g++ 4.2.1</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I download and unzip the source code of OpenCV-3.3.1 from github, make and install it.<br>
Copy opencv.pc to <code class="notranslate">/usr/local/lib/pkgconfig/opencv3.pc</code>.<br>
Finally, fix <code class="notranslate">~/.bash_profile</code> by adding</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export DYLD_LIBRARY_PATH=/Users/yan/opencv-src/opencv-3.3.1/build/lib:$DYLD_LIBRARY_PATH   
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH"><pre class="notranslate"><code class="notranslate">export DYLD_LIBRARY_PATH=/Users/yan/opencv-src/opencv-3.3.1/build/lib:$DYLD_LIBRARY_PATH   
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
</code></pre></div>
<p dir="auto">The problem is when I execute <code class="notranslate">g++ -ggdb `pkg-config --cflags --libs opencv3` opencv_version.cpp -o /tmp/test &amp;&amp; /tmp/test</code> one error comes out:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)"><pre class="notranslate"><code class="notranslate">ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">cmake:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/Users/yan/opencv-src/opencv-3.3.1/build \
-D OPENCV_EXTRA_MODULES_PATH=/Users/yan/opencv-src/opencv_contrib-3.3.1/modules \
-D PYTHON3_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib \
-D PYTHON3_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/ \
-D PYTHON3_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D WITH_CUDA=OFF \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON .."><pre class="notranslate"><code class="notranslate">cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/Users/yan/opencv-src/opencv-3.3.1/build \
-D OPENCV_EXTRA_MODULES_PATH=/Users/yan/opencv-src/opencv_contrib-3.3.1/modules \
-D PYTHON3_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib \
-D PYTHON3_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/ \
-D PYTHON3_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D WITH_CUDA=OFF \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON ..
</code></pre></div>
<p dir="auto">cmake log snippet:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-- General configuration for OpenCV 3.3.1 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /Users/yan/opencv-src/opencv_contrib-3.3.1/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2017-12-06T13:54:50Z
--     Host:                        Darwin 15.6.0 x86_64
--     CMake:                       3.3.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
--       SSE4_1 (3 files):          + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (8 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  (ver 8.0.0.8000042)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 core flann hdf imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres ts bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow sfm stitching python3
--     Disabled:                    js python2 world contrib_world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java viz cnn_3dobj cvv dnn_modern freetype matlab
--
--   GUI:
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.8)
--     JPEG:                        build (ver 90)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.24)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO
--     GDCM:                        NO
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     AVFoundation:                YES
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--     Intel Media SDK:             NO
--     gPhoto2:                     NO
--
--   Parallel framework:            GCD
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Use Intel IPP:               2017.0.3 [2017.0.3]
--                at:               /Users/yan/opencv-src/opencv-3.3.1/build/3rdparty/ippicv/ippicv_mac
--     Use Intel IPP IW:            sources (2017.0.3)
--                   at:            /Users/yan/opencv-src/opencv-3.3.1/build/3rdparty/ippicv/ippiw_mac
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Lapack:                  YES (/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework)
--     Use Eigen:                   YES (ver 3.2.6)
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--     Use OpenVX:                  NO
--     Use custom HAL:              NO
--
--   OpenCL:                        &lt;Link with OpenCL library&gt;
--     Link libraries:              -framework OpenCL
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
--
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.10)
--
--   Python 3:
--     Interpreter:                 /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 (ver 3.6.3)
--     Libraries:                   /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib (ver 3.6.3)
--     numpy:                       /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/include (ver 1.13.3)
--     packages path:               lib/python3.6/site-packages
--
--   Python (for build):            /usr/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:
--     mex:                         /Applications/MATLAB_R2014b.app/bin/mex
--     Compiler/generator:          Not working (bindings will not be generated)
--
--   Documentation:
--     Doxygen:                     NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
--
--   Install path:                  /Users/yan/opencv-src/opencv-3.3.1/build
--
--   cvconfig.h is in:              /Users/yan/opencv-src/opencv-3.3.1/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yan/opencv-src/opencv-3.3.1/build"><pre class="notranslate"><code class="notranslate">-- General configuration for OpenCV 3.3.1 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /Users/yan/opencv-src/opencv_contrib-3.3.1/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2017-12-06T13:54:50Z
--     Host:                        Darwin 15.6.0 x86_64
--     CMake:                       3.3.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
--       SSE4_1 (3 files):          + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (8 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  (ver 8.0.0.8000042)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -fno-omit-frame-pointer -ffunction-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 core flann hdf imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres ts bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow sfm stitching python3
--     Disabled:                    js python2 world contrib_world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java viz cnn_3dobj cvv dnn_modern freetype matlab
--
--   GUI:
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.8)
--     JPEG:                        build (ver 90)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.24)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO
--     GDCM:                        NO
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     AVFoundation:                YES
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--     Intel Media SDK:             NO
--     gPhoto2:                     NO
--
--   Parallel framework:            GCD
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Use Intel IPP:               2017.0.3 [2017.0.3]
--                at:               /Users/yan/opencv-src/opencv-3.3.1/build/3rdparty/ippicv/ippicv_mac
--     Use Intel IPP IW:            sources (2017.0.3)
--                   at:            /Users/yan/opencv-src/opencv-3.3.1/build/3rdparty/ippicv/ippiw_mac
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Lapack:                  YES (/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework)
--     Use Eigen:                   YES (ver 3.2.6)
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--     Use OpenVX:                  NO
--     Use custom HAL:              NO
--
--   OpenCL:                        &lt;Link with OpenCL library&gt;
--     Link libraries:              -framework OpenCL
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
--
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.10)
--
--   Python 3:
--     Interpreter:                 /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 (ver 3.6.3)
--     Libraries:                   /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib (ver 3.6.3)
--     numpy:                       /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/include (ver 1.13.3)
--     packages path:               lib/python3.6/site-packages
--
--   Python (for build):            /usr/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/include
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:
--     mex:                         /Applications/MATLAB_R2014b.app/bin/mex
--     Compiler/generator:          Not working (bindings will not be generated)
--
--   Documentation:
--     Doxygen:                     NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
--
--   Install path:                  /Users/yan/opencv-src/opencv-3.3.1/build
--
--   cvconfig.h is in:              /Users/yan/opencv-src/opencv-3.3.1/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yan/opencv-src/opencv-3.3.1/build
</code></pre></div>
<p dir="auto">opencv3.pc:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Package Information for pkg-config

prefix=/Users/yan/opencv-src/opencv-3.3.1/build
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.3.1
Libs: -L${exec_prefix}/lib -llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib -llibopencv_videostab.3.3.1.dylib -llibopencv_photo.3.3.1.dylib -llibopencv_aruco.3.3.1.dylib -llibopencv_bgsegm.3.3.1.dylib -llibopencv_bioinspired.3.3.1.dylib -llibopencv_ccalib.3.3.1.dylib -llibopencv_dpm.3.3.1.dylib -llibopencv_face.3.3.1.dylib -llibopencv_fuzzy.3.3.1.dylib -llibopencv_hdf.3.3.1.dylib -llibopencv_img_hash.3.3.1.dylib -llibopencv_line_descriptor.3.3.1.dylib -llibopencv_optflow.3.3.1.dylib -llibopencv_reg.3.3.1.dylib -llibopencv_rgbd.3.3.1.dylib -llibopencv_saliency.3.3.1.dylib -llibopencv_sfm.3.3.1.dylib -llibopencv_stereo.3.3.1.dylib -llibopencv_structured_light.3.3.1.dylib -llibopencv_phase_unwrapping.3.3.1.dylib -llibopencv_surface_matching.3.3.1.dylib -llibopencv_tracking.3.3.1.dylib -llibopencv_datasets.3.3.1.dylib -llibopencv_text.3.3.1.dylib -llibopencv_dnn.3.3.1.dylib -llibopencv_plot.3.3.1.dylib -llibopencv_xfeatures2d.3.3.1.dylib -llibopencv_shape.3.3.1.dylib -llibopencv_video.3.3.1.dylib -llibopencv_ml.3.3.1.dylib -llibopencv_ximgproc.3.3.1.dylib -llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib -llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib -llibopencv_flann.3.3.1.dylib -llibopencv_xobjdetect.3.3.1.dylib -llibopencv_imgcodecs.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib -llibopencv_xphoto.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib -llibopencv_core.3.3.1.dylib
Libs.private: 
Cflags: -I${includedir_old} -I${includedir_new}"><pre class="notranslate"><code class="notranslate"># Package Information for pkg-config

prefix=/Users/yan/opencv-src/opencv-3.3.1/build
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.3.1
Libs: -L${exec_prefix}/lib -llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib -llibopencv_videostab.3.3.1.dylib -llibopencv_photo.3.3.1.dylib -llibopencv_aruco.3.3.1.dylib -llibopencv_bgsegm.3.3.1.dylib -llibopencv_bioinspired.3.3.1.dylib -llibopencv_ccalib.3.3.1.dylib -llibopencv_dpm.3.3.1.dylib -llibopencv_face.3.3.1.dylib -llibopencv_fuzzy.3.3.1.dylib -llibopencv_hdf.3.3.1.dylib -llibopencv_img_hash.3.3.1.dylib -llibopencv_line_descriptor.3.3.1.dylib -llibopencv_optflow.3.3.1.dylib -llibopencv_reg.3.3.1.dylib -llibopencv_rgbd.3.3.1.dylib -llibopencv_saliency.3.3.1.dylib -llibopencv_sfm.3.3.1.dylib -llibopencv_stereo.3.3.1.dylib -llibopencv_structured_light.3.3.1.dylib -llibopencv_phase_unwrapping.3.3.1.dylib -llibopencv_surface_matching.3.3.1.dylib -llibopencv_tracking.3.3.1.dylib -llibopencv_datasets.3.3.1.dylib -llibopencv_text.3.3.1.dylib -llibopencv_dnn.3.3.1.dylib -llibopencv_plot.3.3.1.dylib -llibopencv_xfeatures2d.3.3.1.dylib -llibopencv_shape.3.3.1.dylib -llibopencv_video.3.3.1.dylib -llibopencv_ml.3.3.1.dylib -llibopencv_ximgproc.3.3.1.dylib -llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib -llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib -llibopencv_flann.3.3.1.dylib -llibopencv_xobjdetect.3.3.1.dylib -llibopencv_imgcodecs.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib -llibopencv_xphoto.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib -llibopencv_core.3.3.1.dylib
Libs.private: 
Cflags: -I${includedir_old} -I${includedir_new}
</code></pre></div>
<p dir="auto">File <code class="notranslate">/usr/local/lib/pkgconfig/opencv.pc</code> has all the linker flags wrong, and it makes pkg-config unusable for opencv.</p>
<p dir="auto">example:</p>
<p dir="auto">it is:<br>
<code class="notranslate">-llibopencv_stitching.3.3.1.dylib</code></p>
<p dir="auto">it should be:<br>
<code class="notranslate">-lopencv_stitching</code></p>
<p dir="auto">etc.</p>
<p dir="auto">Fresh install OSX 10.13 High Sierra.</p>
<p dir="auto"><code class="notranslate">$ brew config HOMEBREW_VERSION: 1.3.6 ORIGIN: https://github.com/Homebrew/brew HEAD: 270b752f5d9d218bfbed6fe85b6974fa653fb25f Last commit: 3 weeks ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: ade735b9e95352f1731445bad505d920c9521969 Core tap last commit: 3 hours ago HOMEBREW_PREFIX: /usr/local HOMEBREW_REPOSITORY: /usr/local/Homebrew HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com CPU: quad-core 64-bit sandybridge Homebrew Ruby: 2.3.3 =&gt; /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Clang: 9.0 build 900 Git: 2.13.5 =&gt; /Library/Developer/CommandLineTools/usr/bin/git Perl: /usr/bin/perl Python: /usr/local/opt/python/libexec/bin/python =&gt; /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Ruby: /usr/bin/ruby =&gt; /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Java: N/A macOS: 10.13-x86_64 Xcode: 9.1 CLT: 9.0.1.0.1.1506734476 X11: 2.7.11 =&gt; /opt/X11</code></p>
<p dir="auto"><code class="notranslate">$ brew info opencv opencv: stable 3.3.1 (bottled) Open source computer vision library https://opencv.org/ /usr/local/Cellar/opencv/3.3.1_1 (519 files, 95.8MB) * Built from source on 2017-11-08 at 11:53:09 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/opencv.rb ==&gt; Dependencies Build: cmake ✔, pkg-config ✔ Required: eigen ✔, ffmpeg ✔, jpeg ✔, libpng ✔, libtiff ✔, openexr ✔, numpy ✔, tbb ✔ ==&gt; Requirements Required: python ✔, python3 ✔</code></p>
<p dir="auto">Also reported in Homebrew bug tracker: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="272162853" data-permission-text="Title is private" data-url="https://github.com/Homebrew/homebrew-core/issues/20406" data-hovercard-type="issue" data-hovercard-url="/Homebrew/homebrew-core/issues/20406/hovercard" href="https://github.com/Homebrew/homebrew-core/issues/20406">Homebrew/homebrew-core#20406</a></p>