Issue 1 can be solved by telling cmake to turn off transitive linking
mex/CMakeList.txt
set_target_properties(matlabengine PROPERTIES LINK_INTERFACE_LIBRARIES "")
Then, when linking the compiler will search for the library in the library path
environment variable. Because of issue 2, the system standard library folder should precede the matlab library folder like so in linux:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:/usr/local/MATLAB/R2013a/bin/glnxa64/