title: Linking error with `libopencv_highgui.so` under Ubuntu 14.04, strange result with `libtiff.so.5`
body: <h1>Problem</h1>
  
  <p>I'm compiling the deep learning library <a href="http://caffe.berkeleyvision.org/">Caffe</a> in Ubuntu 14.04(64 bit).</p>
  
  <p>OpenCV(<code>Version: 2.4.8+dfsg1-2ubuntu1</code>) is installed from ubuntu packages server with :</p>
  
  <blockquote>
    <p>sudo apt-get install libopencv-dev</p>
  </blockquote>
  
  <p>Compile <code>Caffe</code> with CMake 2.8. </p>
  
  <p>Linking error:</p>
  
  <blockquote>
    <p>Linking CXX executable caffe-</p>
    
    <p>/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.8: undefined reference to `TIFFOpen@LIBTIFF_4.0'</p>
  </blockquote>
  
  <h1>Infomation</h1>
  
  <p>It seems some symbols of TIFF library were not found. I made some effort to find the reason(without luck). Here's some infomation about the libraries.</p>
  
  <p><strong>TIFF library linked by <code>libopencv_highgui.so.2.4.8</code></strong></p>
  
  <blockquote>
    <p>$ ldd libopencv_highgui.so.2.4.8 | grep tiff</p>
    
    <p>libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f978313b000)</p>
  </blockquote>
  
  <p><strong>Import symbols of <code>libopencv_highgui.so.2.4.8</code></strong></p>
  
  <blockquote>
    <p>$ readelf -s libopencv_highgui.so.2.4.8 |grep TIFFOpen</p>
    
    <p>62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND <strong>TIFFOpen@LIBTIFF_4.0 (9)</strong></p>
  </blockquote>
  
  <p><strong>Note</strong>: There is one single <code>@</code> in the symbol names.</p>
  
  <blockquote>
    <p>$ nm -D libopencv_highgui.so.2.4.8| grep TIFFOpen</p>
    
    <p>U TIFFOpen</p>
  </blockquote>
  
  <p><strong>Export symbols of <code>libtiff.so.5</code>:</strong></p>
  
  <blockquote>
    <p>$ nm -D /usr/lib/x86_64-linux-gnu/libtiff.so.5</p>
    
    <p>0000000000000000 A LIBTIFF_4.0</p>
    
    <p>...</p>
    
    <p>00000000000429f0 T TIFFOpen</p>
    
    <p>...</p>
    
    <p>$ readelf -s /usr/lib/x86_64-linux-gnu/libtiff.so.5|grep TIFFOpen</p>
    
    <p>99: 00000000000429f0   239 FUNC    GLOBAL DEFAULT   12 <strong>TIFFOpen@@LIBTIFF_4.0</strong></p>
  </blockquote>
  
  <p><strong>Note</strong>: There are two <code>@</code>(<code>@@</code>) in the symbol names.</p>
  
  <h1>My confusion</h1>
  
  <p><ol>
  <li>Is it because <code>libtiff.so.5</code> has <code>@@</code> in the symbol names instead of <code>@</code> that made the linking error</p>
  
  <blockquote>
    <p>libopencv_highgui.so.2.4.8: undefined reference to 'TIFFIsTiled@LIBTIFF_4.0'</li>
    <li>What's the difference between <code>@</code> and <code>@@</code> in symbol names?</li>
    <li>What's the meaning of the suffix <code>LIBTIFF_4.0</code> of symbols names in <code>libtiff.so.5</code>?</li>
    <li>Many people said it's because OpenCV need <code>libtiff4-dev</code> which is not provided by Ubuntu 14.04. Then why the Ubuntu guys put a broken package on the package server.</li>
    <li>How to solve the linking problem?</li>
    </ol></p>
    
    <hr>
  </blockquote>
  
  <p>I'm not a profession on compiling and linking. Sorry for such a long post. Just what to provide enough infomation for you guys to help me.
  Appreciate for any suggestions. </p>
  
  <p><strong>P.S.</strong> If you need more infomation of those libs, feel free to say in the comment.</p>