Using system() to Run LibreOffice / soffice on OSX

1 view (last 30 days)
I'm running MATLAB 2013a on OSX and am attempting to convert a .xlsx file to a .pdf using MATLAB script. After determining that this couldn't be achieved using MATLAB alone, I downloaded LibreOffice to help me out. Running the following code in Mac Terminal works perfectly:
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx
This code saves the file box_copy.xlsx as a .pdf on my desktop. However, when I try running the same code in MATLAB using system():
system('/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx')
the .pdf does not get saved, and I get the error
dyld: Library not loaded: @loader_path/libcurl.4.dylib
Referenced from: /Applications/LibreOffice.app/Contents/Frameworks/libvcllo.dylib
Reason: Incompatible library version: libvcllo.dylib requires version 8.0.0 or later, but libcurl.4.dylib provides version 7.0.0
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx: Trace/breakpoint trap
Does anyone have a solution for this error? Thanks for the help!

Accepted Answer

Walter Roberson
Walter Roberson on 5 Oct 2015
You will need to set the environment variable DYLD_LIBRARY_PATH and possibly DYLD_FRAMEWORK_PATH as well, to point to different libraries. You can do that inside MATLAB by using setenv() before you system(), or you can do it on the command line that you system(). It also might work to unset DYLD_LIBRARY_PATH
system('unsetenv DYLD_LIBRARY_PATH; /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx')
  2 Comments
Miles
Miles on 5 Oct 2015
Edited: Miles on 5 Oct 2015
Thanks for the response. I tried running
system('unsetenv DYLD_LIBRARY_PATH; /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx')
but got
/bin/bash: unsetenv: command not found
dyld: Library not loaded: @loader_path/libcurl.4.dylib
Referenced from: /Applications/LibreOffice.app/Contents/Frameworks/libvcllo.dylib
Reason: Incompatible library version: libvcllo.dylib requires version 8.0.0 or later, but libcurl.4.dylib provides version 7.0.0
/bin/bash: line 1: 32465 Trace/BPT trap: 5 /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx
unsetenv DYLD_LIBRARY_PATH; /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/dwm8/Desktop/ /Users/dwm8/Desktop/box_copy.xlsx: Trace/breakpoint trap
What would the code be to set the environment variables DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH? Sorry for the dumb questions, I've never used the setenv() function and couldn't understand what I read on the help page.
Miles
Miles on 5 Oct 2015
Nevermind, I just got it thanks to your help! I just inserted the line
setenv DYLD_LIBRARY_PATH
above the code I had previously entered and it worked perfectly, thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!