Open Firefox or Chrome from Matlab script on Linux

4 Ansichten (letzte 30 Tage)
Joseph Areeda
Joseph Areeda am 23 Feb. 2012
Bearbeitet: Matt J am 25 Okt. 2013
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
Joseph Areeda
Joseph Areeda am 25 Feb. 2012
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
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
Joseph Areeda
Joseph Areeda am 23 Feb. 2012
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 Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by