Search code examples
bashmatlabvimenvironment-variablesmlint

mlint syntax checking in vim


I tried to get the MATLAB syntax checking to work in Vim.

I used Bundle 'jrestrepo/matlab' and for syntax highlighting and it works fine. But the syntax checking doesn't work. I exported /Applications/MATLAB_R2012b.app/bin/maci64/ to PATH with:

PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"
export PATH
export PATH=$PATH:/Applications/MATLAB_R2012b.app/bin/maci64

in my bash_profile and now on the command line I get:

Tierra-Gorda:~ mike$ which mlint
/Applications/MATLAB_R2012b.app/bin/maci64/mlint

Tierra-Gorda:~ mike$ mlint
dyld: Library not loaded: libtbb.dylib
  Referenced from: /Applications/MATLAB_R2012b.app/bin/maci64/./libmwfl.dylib
  Reason: image not found
Trace/BPT trap: 5

and I suspect, that the dot in the path messes it up somehow. Because the file libmwfl.dylib exists in .../maci64/libmwfl.dylib.

Thanks for any suggestions.


Solution

  • You probably want to set the DYLD_LIBRARY_PATH environment variable in addition to PATH:

    export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/MATLAB_R2012b.app/bin/maci64
    

    According to man dyld:

    DYLD_LIBRARY_PATH

    This is a colon separated list of directories that contain libraries. The dynamic linker searches these directories before it searches the default locations for libraries. It allows you to test new versions of existing libraries.

    For each library that a program uses, the dynamic linker looks for it in each directory in DYLD_LIBRARY_PATH in turn. If it still can't find the library, it then searches DYLD_FALLBACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH in turn.

    Use the -L option to otool(1) to discover the frameworks and shared libraries that the executable is linked against.


    EDIT:

    I think a safer way is to append to DYLD_FALLBACK_LIBRARY_PATH instead. That way you don't take precedence over the default search path, and possibly override libraries loaded by other programs...

    Even better, you should create a launcher script (where you set DYLD_* then start mlint), as opposed to changing the environment variables globally in your bash_profile.