First, my system info:
- 4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Clean installation of Matlab R2016b (64-bit)
- Video card: AMD/ATI Pitcairn PRO (Radeon HD 7850)
Problems with Vanilla Install
So, I start up Matlab from the command line with no arguments. I've set two environment variables, LIBGL_DEBUG=verbose
and MESA_DEBUG=1
, to get detailed printouts of any bugs. The software starts with no errors. Next, I issue a simple plot command:
plot(1,1, 'b*'); grid on;
Matlab creates the plot successfully, but issues a series of errors, saying that there was a low-level graphics error. From the command line I see the following messages:
libGL: pci id for fd 570: 1002:6819, driver radeonsi
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/radeonsi_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
libGL: dlopen /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so failed (/opt/local/MATLAB/R2016b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so))
There are many more, but the end result is the same: the linker cannot load the graphics drivers with the libstdc++.so file Matlab has loaded. To fix this issue, I rename the relevant libraries that come with Matlab to force it to use the system libraries (which include version GLIBCXX_3.4.21
):
cd /opt/local/MATLAB/R2016b/sys/os/glnxa64
mv libstdc++.so.6 libstdc++.so.6.bak
mv libstdc++.so.6.0.20 libstdc++.so.6.0.20.bak
Problems with Modified Install
With the C++ libraries renamed to force Matlab to link with the system libraries, I restart Matlab. The environment variables are still set, so any libgl or mesa errors should be reported to the terminal. Immediately after the program starts, I receive the following error in Matlab:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x7c1bc33e, isOwner false, <2af5b1a, 46860956>[count 0, qsz 0, owner <NULL>]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
Exception in thread "Startup Class Loader" java.lang.InternalError: XXX0 profile[1]: GL3bc -> profileImpl GL4bc !!! not mapped
at com.jogamp.opengl.GLProfile.computeProfileMap(GLProfile.java:2047)
at com.jogamp.opengl.GLProfile.initProfilesForDeviceCritical(GLProfile.java:1917)
at com.jogamp.opengl.GLProfile.initProfilesForDevice(GLProfile.java:1866)
at com.jogamp.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1835)
at com.jogamp.opengl.GLProfile.access$000(GLProfile.java:79)
at com.jogamp.opengl.GLProfile$1.run(GLProfile.java:229)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:215)
at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:147)
at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:117)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:262)
at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25)
at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:248)
at java.lang.Thread.run(Unknown Source)
Additionally, the following messages are displayed in the Terminal output:
libGL: pci id for fd 570: 1002:6819, driver radeonsi
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/radeonsi_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
libGL: Using DRI3 for screen 0
These messages don't indicate any troubles; it looks like the radeonsi_dri object is loaded successfully. When I try the same plot command as above, I receive the following message in Matlab:
Caught unexpected fl::except::IInternalException
The figure shows an empty image; the plot has not been created.
Other Notes
- I've also tried renaming the
libgcc_s.so.1
library in Matlab's directory so that it uses the system version, but that doesn't change anything. - There are no errors (EE) in my Xorg.0.log file
- I've successfully benchmarked OpenGL and the video card with
glmark2
, i.e., OpenGL runs very well with hardware accelleration on my machine, but Matlab has some issue. - Matlab R2016b ships with
libGL.so.1.6.0
(inR2016b/sys/opengl/lib/glnxa64
) but my OS version islibGL.so.1.2.0
). Could this cause an issue? I tried renaming the libGL files shipped with Matlab to force it to use the system versions, but the error messages are still the same. - With the modified libstdc++ files, I can run Matlab in software openGL mode via the command
matlab -softwareopengl
. Plotting works fine, though Mesa spits out the warning/error,User error: GL_INVALID_ENUM in glGetIntegerv(pname=GL_MAJOR_VERSION)