title: Cannot find -lpython2 : MatCaffe installation error
body: <p>During the build of MatCaffe (Matlab wrapper of Caffe), I face the following error :</p>
  
  <pre><code>[ 96%] Built target convert_mnist_data
  [ 96%] Built target convert_mnist_siamese_data
  [ 98%] Built target pycaffe
  [100%] Building Matlab interface: /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.mexa64
  Building with 'g++'.
  Warning: You are using gcc version '4.8.2'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
  Warning: You are using gcc version '4.8.2-19ubuntu1)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
  /usr/bin/ld: cannot find -lpython2
  collect2: error: ld returned 1 exit status
  
  make[2]: *** [../matlab/+caffe/private/caffe_.mexa64] Error 255
  make[1]: *** [matlab/CMakeFiles/matlab.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>On closer examination I found using following command that the following file is responsible for the above error : </p>
  
  <pre><code> grep -rnw "./" -e "-lpython2"
  </code></pre>
  
  <p>It revealed to me the following :</p>
  
  <pre><code>./matlab/CMakeFiles/matlab.dir/build.make:53:   cd /home/trunks/Downloads/caffe-master/build/matlab &amp;&amp; /usr/local/MATLAB/R2014a/bin/mex -output /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.mexa64 /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.cpp -DCPU_ONLY -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -I/home/trunks/Downloads/caffe-master/src -I/usr/include -I/home/trunks/Downloads/caffe-master/build/external/glog-install/include -I/home/trunks/Downloads/caffe-master/build/external/gflags-install/include -I/home/trunks/Downloads/caffe-master/build/include -I/usr/local/include/opencv -I/usr/local/include -I/usr/include/python2.7 -I/home/trunks/anaconda/lib/python2.7/site-packages/numpy/core/include -I/home/trunks/Downloads/caffe-master/include -I/home/trunks/Downloads/caffe-master/build -L/home/trunks/Downloads/caffe-master/build/lib -L/usr/lib/x86_64-linux-gnu -L/home/trunks/Downloads/caffe-master/build/external/gflags-install/lib -L/home/trunks/Downloads/caffe-master/build/external/glog-install/lib -L/usr/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lcaffe -lboost_system -lboost_thread -lpthread -lgflags -lglog -lhdf5_hl -lhdf5 -llmdb -lleveldb -lsnappy -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopenblas -lpython2 -lboost_python -lprotobuf
  </code></pre>
  
  <p>So, I changed the corresponding -lpython2 to -lpython2.7 with the hope of resolving the problem. But to no yield.</p>
  
  <p>I also tried the following :</p>
  
  <ol>
  <li>Delete the CMakeCache.txt and doing the make. But it did not work.</li>
  <li><p>I edited the default CMakeLists.txt file in /cmake-master, to change some default settings. I found that the default python version setting in the CMakeLists.txt in Caffe is 2 .</p>
  
  <p>//Specify which python version to use
      python_version:STRING=2.7</p></li>
  </ol>
  
  <p>I changed it to 2 , and repeated the whole configure-generate-make process in a fresh build folder. But to no yield. Everytime the same matlab/build.make file shows -lpython2 , and changing that to 2.7 directly does not yield.</p>
  
  <ol start="3">
  <li>I tried to look into matlab/build.make file but could not find anything over there which I could directly connect with this error.</li>
  </ol>
  
  <p>Any solid help would be deeply appreciated. I use MATLAB 2014a, on Ubuntu 14.04.</p>