title: Compiles using clang, but not g++5 - ld: symbol(s) not found for architecture x86_64
body: <p>I have an OpenCV program that compiles using clang without and errors, I am looking to try and compile this program using g++5 however I am getting the following error:</p>
  
  <pre><code>ld: symbol(s) not found for architecture x86_64
  </code></pre>
  
  <p>The command I am using when trying to build the file is:</p>
  
  <pre><code>g++-5 -std=c++11 -pthread main.cpp -o testcomp `pkg-config --cflags --libs opencv`
  </code></pre>
  
  <p>Am I correct in assuming that the OpenCV libraries are 32 bit but g++5 is designed for 64 bit?</p>
  
  <p>If I try to compile the code using the following command, the program builds successfully:</p>
  
  <pre><code>g++ -std=c++11 -pthread main.cpp -o testComp `pkg-config --cflags --libs opencv`
  </code></pre>
  
  <p>I am using OSX and have installed g++ through home-brew.</p>
  
  <p>The full compilation error is below:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "cv::drawMatches(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt; const&amp;, cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt; const&amp;, std::vector&lt;cv::DMatch, std::allocator&lt;cv::DMatch&gt; &gt; const&amp;, cv::Mat&amp;, cv::Scalar_&lt;double&gt; const&amp;, cv::Scalar_&lt;double&gt; const&amp;, std::vector&lt;char, std::allocator&lt;char&gt; &gt; const&amp;, int)", referenced from:
        processingThread(cv::Mat, int)  in ccw6qwZp.o
    "cv::FeatureDetector::create(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
        __static_initialization_and_destruction_0(int, int) in ccw6qwZp.o
    "cv::DescriptorExtractor::create(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
        __static_initialization_and_destruction_0(int, int) in ccw6qwZp.o
    "cv::imread(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int)", referenced from:
        _main in ccw6qwZp.o
    "cv::imshow(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, cv::_InputArray const&amp;)", referenced from:
        _main in ccw6qwZp.o
    "cv::FeatureDetector::detect(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt;&amp;, cv::Mat const&amp;) const", referenced from:
        preProcessing()     in ccw6qwZp.o
        processingThread(cv::Mat, int)  in ccw6qwZp.o
    "cv::DescriptorMatcher::match(cv::Mat const&amp;, cv::Mat const&amp;, std::vector&lt;cv::DMatch, std::allocator&lt;cv::DMatch&gt; &gt;&amp;, cv::Mat const&amp;) const", referenced from:
        processingThread(cv::Mat, int)  in ccw6qwZp.o
    "cv::DescriptorExtractor::compute(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt;&amp;, cv::Mat&amp;) const", referenced from:
        preProcessing()     in ccw6qwZp.o
        processingThread(cv::Mat, int)  in ccw6qwZp.o
  ld: symbol(s) not found for architecture x86_64
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Compiler output as per comment with <code>-Wl,-v</code> added:</p>
  
  <pre><code>collect2 version 5.2.0
  /usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -weak_reference_mismatches non-weak -o testcomp -L/usr/local/lib -L/usr/local/Cellar/gcc5/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.2.0 -L/usr/local/Cellar/gcc5/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.2.0/../../.. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib -v /var/folders/nc/_drhkj6n3fnd1g3jmwq8mtm80000gn/T//ccfpdMCy.o -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem
  @(#)PROGRAM:ld  PROJECT:ld64-253.3.3
  configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
  Library search paths:
      /usr/local/lib
      /usr/local/Cellar/gcc5/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin15.0.0/5.2.0
      /usr/local/Cellar/gcc5/5.2.0/lib/gcc/5
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib
  Framework search paths:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/
  Undefined symbols for architecture x86_64:
    "cv::drawMatches(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt; const&amp;, cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt; const&amp;, std::vector&lt;cv::DMatch, std::allocator&lt;cv::DMatch&gt; &gt; const&amp;, cv::Mat&amp;, cv::Scalar_&lt;double&gt; const&amp;, cv::Scalar_&lt;double&gt; const&amp;, std::vector&lt;char, std::allocator&lt;char&gt; &gt; const&amp;, int)", referenced from:
        processingThread(cv::Mat, int)  in ccfpdMCy.o
    "cv::FeatureDetector::create(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
        __static_initialization_and_destruction_0(int, int) in ccfpdMCy.o
    "cv::DescriptorExtractor::create(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
        __static_initialization_and_destruction_0(int, int) in ccfpdMCy.o
    "cv::imread(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int)", referenced from:
        _main in ccfpdMCy.o
    "cv::imshow(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, cv::_InputArray const&amp;)", referenced from:
        _main in ccfpdMCy.o
    "cv::FeatureDetector::detect(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt;&amp;, cv::Mat const&amp;) const", referenced from:
        preProcessing()     in ccfpdMCy.o
        processingThread(cv::Mat, int)  in ccfpdMCy.o
    "cv::DescriptorMatcher::match(cv::Mat const&amp;, cv::Mat const&amp;, std::vector&lt;cv::DMatch, std::allocator&lt;cv::DMatch&gt; &gt;&amp;, cv::Mat const&amp;) const", referenced from:
        processingThread(cv::Mat, int)  in ccfpdMCy.o
    "cv::DescriptorExtractor::compute(cv::Mat const&amp;, std::vector&lt;cv::KeyPoint, std::allocator&lt;cv::KeyPoint&gt; &gt;&amp;, cv::Mat&amp;) const", referenced from:
        preProcessing()     in ccfpdMCy.o
        processingThread(cv::Mat, int)  in ccfpdMCy.o
  ld: symbol(s) not found for architecture x86_64
  collect2: error: ld returned 1 exit status
  </code></pre>