Open Firefox or Chrome from Matlab script on Linux

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 Kommentare

I have more information.
It turns out the Scientific Linux problem was not Matlab but me (surprise, surprise). That system is working now.
But the Ubuntu one seems real enough. Take my program out of the picture and run Matlab on Ubuntu 11.04 with all updates.
status = web('http://www.mathworks.com')
returns 0 signifying success but the windows says "This page does not display correctly in your version of the MATLAB Web Browser." And gives a link "Please use the link below to open the page in your default system browser:
http://www.mathworks.com/index.html"
but clicking on it does nothing.
status = web('http://www.mathworks.com', '-browser')
Also returns 0 but no browser is opened.
[status, result] = system('firefox http://www.mathworks.com')
gives:
status =
1
result =
/usr/lib/chromium-browser/chromium-browser: /usr/local/MATLAB/R2011b/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/chromium-browser/chromium-browser)
/usr/lib/chromium-browser/chromium-browser: /usr/local/MATLAB/R2011b/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/chromium-browser/chromium-browser)
Googling `GLIBCXX_3.4.11' not found suggests I have an incompatible version of gcc/g++ libraries on my system.
I have the latest released in the Ubuntu repositories:
$ g++ --version
g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Do I need to find a version 3.4 of libstdc++ to do this?
If so anyone know how to do that so I can both run Matlab and an only mildly out of date version of g++. According to gnu the latest is 4.6.2 and 3.4.6 is from 2006.
I am running Matlab 2011b downloaded and installed about 2 weeks ago.
Jason Ross
Jason Ross am 24 Feb. 2012
I would have thought that the browser would have installed all it's required dependencies if you did it using apt (or the package manager). But you should be able to install the older libraries on the system if you need to.
Jason,
Yes both Firefox and Chrome were installed with the "Ubuntu Software Center" which uses apt.
Both browsers work fine outside of Matlab, so I don't believe it is a browser installation problem.
I just thought of the possibility of using the system command to run a shell to check the environment variables Matlab is using.
I'll report back.
Does anybody know which versions of the gcc/g++ libraries run with which versions of Matlab? I hope to support Matlab back a couple of years probably 2009a.
Also where should the old libraries be placed so as not to interfere with non-Matlab usage?
Jason Ross
Jason Ross am 24 Feb. 2012
The systems requirements pages are archived for several releases:
http://www.mathworks.com/support/sysreq/current_release/
for 2009a in particular:
http://www.mathworks.com/support/sysreq/release2009a/linux.html
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 am 27 Feb. 2012
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jason Ross
Jason Ross am 23 Feb. 2012

0 Stimmen

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 Kommentare

Jason Ross
Jason Ross am 23 Feb. 2012
FWIW I just tried this out with Firefox (really, Iceweasel) and Chrome. The command I used for Chrome was "google-chrome", which resolves to "/usr/bin/google-chrome". In both cases,
web('http://www.google.com', '-browser')
did what I expected, opening the browser to the url indicated.
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 am 24 Feb. 2012
Yep. I got mine right from Google by adding it to my sources and installing it using aptitide.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Platform and License finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 23 Feb. 2012

Bearbeitet:

am 25 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by