title: MATLAB mex function using a shared library yields conflict
body: <p>I am building a C mex file (for MATLAB) which links with a shared library (say A.so), and A.so depends on functions provided by B.so.  However, MATLAB also uses B.so separately but ships with its own, older version.  When the mex function runs in MATLAB it calls a function in A.so (successfully) but when that function calls a lower-level function in B.so it incorrectly switches to the older B.so provided with MATLAB, and a crash or compatibility error ensues.</p>
  
  <p>I believe if I built A.so using the older version of B.so then this problem might go away.  However, it is not practical to insist than all users of the mex function I am building must do this.  Most users will have installed A.so via a package manager and thus their A.so relies on a more recent B.so than MATLAB's.</p>
  
  <p>So my question is this: Is it possible (via linker flags) to force calls to A.so to look in B.so for its required sub-functions? Or is MATLAB taking control and there is nothing I can do to override this undesired behavior other than build a version of A.so linked against the older libraries?</p>
  
  <p>I hope this problem is due to my very incomplete knowledge of how MATLAB resolves shared libraries it knows about and the ones an external mex function may require.  I am in need of a solution that is cross-platform (Win, OS X, Linux).</p>