Lock the mex file to avoid Matlab crashes.

Commands like "clear all" and "clear function" causes segmentation faults or errors like these (especially after an 'init'):
 libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto
 libprotobuf FATAL google/protobuf/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
 [libprotobuf ERROR google/protobuf/message.cc:333] Type appears to be in generated pool but wasn't registered: caffe.LayerParameter
 Attempt to restart MATLAB?
To avoid these, lock the the mex file.
Changed linking order: -pthread -> back.
Otherwise error:
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): undefined reference to symbol 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[pycaffe] add converter for vectors of Nets
[pycaffe] expose SGDSolver.test_nets
add accessor for Solver::iter_

This will be useful in code controlling the solver (from pycaffe, for
example).
[pycaffe] expose SGDSolver.iter
Merge pull request #951 from gcinbis/patch-1

Lock the mex file to avoid MATLAB crashes
[fix] lint causing travis failures
Update detect.py

This generator causes an error in detect_windows because it is run twice there.
Better store it as a data structure instead.
Merge pull request #1198 from dbbert/patch-1
Back-merge to include #1198
add factory header to caffe hpp
[pycaffe] expose Net::CopyTrainedLayersFrom as Net.copy_from

This allows finetuning from Python, for example.
Merge pull request #1196 from longjon/python-solver-improvements

Python solver improvements
[pycaffe] expose Net::SharedTrainedLayersWith as Net.share_with
Merge pull request #1208 from Yangqing/dev

add factory header to caffe hpp
Add caffe_gpu_exp math function
Add ExpLayer to calculate y = base ^ (scale * x + shift)
[fix] comment typo
save/restore shared weights unit test