Matlab installation (LD_LIBRARY_PATH) messes up other library files
Question: I am trying to install Matlab on a Linux machine, but setting LD_LIBRARY_PATH
(as the installation requires) breaks other library files. I am not an Linux
expert, but I have tried several things and cannot get it working correctly. I
have even contacted Matlab support, got the issue elevated to the dev team,
and was basically told "haha sucks to suck". I have seen a few other people
online have had the same issue, but either their questions were never answered
or they had a slightly different problem and their solution didn't apply to
me.

**Installing on a VM running Ubuntu:**

I set LD_LIBRARY_PATH as the instructions say, then it breaks network files. I
can ping google.com, but I cannot nslookup google.com or visit it in a
browser. Nslookup provides this error:

    
    
    nslookup: /usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64/libcrypto.so.1.0.0: no version information available (required by /usr/lib/libdns.so.100)
    03-Feb-2016 11:32:22.361 ENGINE_by_id failed (crypto failure)
    03-Feb-2016 11:32:22.362 error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
    03-Feb-2016 11:32:22.363 error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:eng_dyn.c:447:
    03-Feb-2016 11:32:22.363 error:2606A074:engine routines:ENGINE_by_id:no such engine:eng_list.c:418:id=gost
    (null): dst_lib_init: crypto failure
    

The installation worked though (I can run my Java programs that reference
compiled Matlab functions). Unsetting LD_LIBRARY_PATH fixes the network files
but then I can't run programs anymore.

**Installing on EC2 instance:**

On an EC2 instance it does not break the network files (nslookup is fine).
Instead it messes up Python library files. Trying to use any aws cli command,
I get the error:

    
    
    File "/usr/bin/aws", line 19, in <module>
      import awscli.clidriver
    File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 16, in <module>
      import botocore.session
    File "/usr/lib/python2.7/dist-packages/botocore/session.py", line 25, in <module>
      import botocore.config
    File "/usr/lib/python2.7/dist-packages/botocore/config.py", line 18, in <module>
      from botocore.compat import six
    File "/usr/lib/python2.7/dist-packages/botocore/compat.py", line 139, in <module>
      import xml.etree.cElementTree
    File "/usr/lib64/python2.7/xml/etree/cElementTree.py", line 3, in <module>
      from _elementtree import *
    ImportError: PyCapsule_Import could not import module "pyexpat"
    

Printing sys.path in Python shows lib-dynload is already there though, so it
doesn't seem to the problem.

And when trying to run the program, I get:

    
    
    Exception in thread "main" java.lang.LinkageError: libXt.so.6: cannot open shared object file: No such file or directory
    at com.mathworks.toolbox.javabuilder.internal.DynamicLibraryUtils.dlopen(Native Method)
    at com.mathworks.toolbox.javabuilder.internal.DynamicLibraryUtils.loadLibraryAndBindNativeMethods(DynamicLibraryUtils.java:134)
    at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1529)
    at VectorAddExample.VectorAddExampleMCRFactory.newInstance(VectorAddExampleMCRFactory.java:48)
    at VectorAddExample.VectorAddExampleMCRFactory.newInstance(VectorAddExampleMCRFactory.java:59)
    at VectorAddExample.VectorAddClass.<init>(VectorAddClass.java:62)
    at com.mypackage.Example.main(Example.java:13)
    

I'm at a brick wall and really have no clue how to proceed.


Answer: Maybe something else already needs LD_LIBRARY_PATH set to work. Make sure you
prepend not overwrite:

    
    
    export LD_LIBRARY_PATH=new/path:$LD_LIBRARY_PATH
    

**Edit** :

OK, if LD_LIBRARY_PATH was initially empty, this suggests that Matlab comes
with shared libraries that are incompatible with your system ones:

    
    
    nslookup: /usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64/libcrypto.so.1.0.0: no version information available (required by /usr/lib/libdns.so.100)
    

suggests that `/usr/lib/libdns.so.100` needs `libcrypto.so.1.0.0`, which is
now being resolved to the one that comes with MATLAB, which is incompatible.

You can check the dependencies of a dll by

    
    
    ldd /usr/lib/libcrypto.so.1.0.0
    

and hopefully you can find a configuration that keeps both MATLAB and your
system happy. Unfortunately, this may involve a lot of trial and error.

If there is no such configuration, you can try setting LD_LIBRARY_PATH only
when you run MATLAB:

LD_LIBRARY_PATH=$MATLAB_LD_LIBRARY_PATH matlab

**Edit 2** :

Well, for the Python issue, it seems to boil down to `pyexpat`, which is a
wrapper around the standard `expat` XML parser. Try doing (name guessed since
I don't have a Linux right now):

ldd /usr/local/lib/python2.7/site-packages/libpyexpat.so

and see what that depends on. Probably, it will be `libexpat.so`, which is now
being resolved to MATLAB's version.

