Using system() to Run LibreOffice / soffice on OSX

1 次查看(过去 30 天)
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!

采纳的回答

Walter Roberson
Walter Roberson 2015-10-5
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 个评论
Miles
Miles 2015-10-5
编辑:Miles 2015-10-5
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 2015-10-5
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by