Open Firefox or Chrome from Matlab script on Linux

4 次查看(过去 30 天)
So I had what I thought was a good idea that has come back to bite me during cross platform testing.
I put little ? icons all over the GUI for context sensitive help. Since the boss is pushing hard for a release, I figured this was a good way to be able to distribute the program while we enhanced the context sensitive help and documentation. (The program uses the web for data transfers anyway).
The problem is in Linux specifically Ubuntu 11.04 and Scientific Linux 6.1 (a Fedora derivative)
stat = web (url, '-browser')
works fine on MacOS and Windows but on linux it returns 0 signifying "Browser was found and launched." see http://www.mathworks.com/help/techdoc/ref/web.html
BUT no browser opens. Preferences->Web is set to firefox or chromium-browser or /usr/bin/firefox or /usr/bin/chromium-browser
All of those commands work just fine from the terminal windows I use to launch Matlab and from the GNOME application launch panel.
Running: [stat,result]=system('firefox www.matworks.com') does give error messages indicating some dynamic libraries are not found.
I assume that the problem with the web function also.
Anyone know how to fix this in a hopefully general way that doesn't rely on my startup script parsing the entire /etc/ld.so.conf.d directory and populating LD_LIBRARY_PATH?
Thanks,
Joe
  6 个评论
Joseph Areeda
Joseph Areeda 2012-2-25
I really appreciate your help with this Jason. I can't seem to wrap my ahead around the real problem.
I THINK I've been looking at this backwards and the problem is not what OLD libraries are available on the system but what NEW libraries are NOT available to programs that run in Matlab environment.
If we assume that the web(url, '-browser') function is equivalent to system('firefox -no-remote url') then one way to explore the dependencies is with
[status, result] = system('ldd /usr/lib/firefox-10.0.2/firefox')
note that on Ubuntu /usr/bin/firefox is a symbolic link to a shell script.
There are 2 differences between ldd inside and outside Matlab:
libstdc++.so.6 => /usr/local/MATLAB/R2011b/sys/os/glnxa64/libstdc++.so.6 (0x00007fd58e97e000)
libgcc_s.so.1 => /usr/local/MATLAB/R2011b/sys/os/glnxa64/libgcc_s.so.1 (0x00007fd58e4e2000)
I believe that what's going on is that these libraries are incompatible with the latest version of the browser.
Next I want to check if that version of Chrome you have from Google is perhaps statically linked or if I can find a browser in the Ubuntu repositories that works with R2011b.
Joe
Jason Ross
Jason Ross 2012-2-27
I did some digging.
/usr/bin/google-chrome is a sym link to /opt/google/chrome/google-chrome.
/opt/google/chrome/google-chrome is a script. It does a number of things to set the environment and then finally execs the chrome executable.
The chrome executable itself returns a number of libs in /usr/lib and /lib

请先登录,再进行评论。

回答(1 个)

Jason Ross
Jason Ross 2012-2-23
You can check and see how your system "knows" the browser:
I had a similar problem getting links to launch in Chrome, and had to do the above procedure to make my Linux machine launch Chrome when I expected it to. I don't know with 100%% certainty that this will solve your issue, but it's a good place to start.
  3 个评论
Joseph Areeda
Joseph Areeda 2012-2-23
Thank you Jason.
I followed your link but "update-alternatives" was already set to chrome
I don't have subdirectory in ~/.gconf but I think that part is to specify which browser to launch a browser to examine a local file with an xml. If I right click on an html file I can open it in Chrome from the menu. If I right click on a .xml file it opens in Firefox.
It's interesting that your browser is called 'google-chrome' and mine is called chromium-browser. I suspect you downloaded yours from Google while I used the Ubuntu repository.
I am running: 16.0.912.77 (Developer Build 118311 Linux) Ubuntu 11.04
I still can't open anything from inside Matlab. I wonder what it is?
Joe
Jason Ross
Jason Ross 2012-2-24
Yep. I got mine right from Google by adding it to my sources and installing it using aptitide.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by