Invalid MEX-file Screen problem

Hi there, I'm on Ubuntu 14.04 LTS 64-bit running Matlab R2015b (64-bit) academic user, and I continue to run into this problem, even when reinstalling or doing different kinds of diagnostics. It seems for some reason I can't use the Screen() function. I receive this error when I do:

Invalid MEX-file '/home/lab/Documents/MATLAB/Psychtoolbox/PsychBasic/Screen.mexa64': cannot open shared object file: No such file or directory

I was reading online about moving or deleting the lib*.so* files, however the one it seems to be trying to use ( isn't in the directory with the rest of the lib*.so* files. Its as if it doesn't exist (unless by they meant [closest looking file I could see]). Anyways, I'm quite stuck with trying to get this to work. Perhaps it is because the lib*.so* files are in usr/local/MATLAB/R2015b/bin/glnxa64 directory, and it doesn't share the same directory as Screen.mexa64? Though I'm not sure, but if that is the case I'd appreciate how to fix that. If not, I'd appreciate any help or assistance in this situation!



sudo apt-get install libdc1394-22

libdc1394 is a required dependency for Screen(). The most easy way to get Psychtoolbox on Ubuntu/Debian is to use the NeuroDebian repository, as recommended. That will automatically install all required libraries.


Hi all,

Just wanted to update anyone who runs into the same issue with libdc1394. It’s been about 5 years since this issue was encountered but it’s back. I tried to install PTB via NeuroDebian onto a Pop!_OS 20.10 laptop today. I had the exact same “Invalid MEX-file” error as above.

My solution was to abandon the NeuroDebian installation and to instead use the DownloadPsychtoolbox.m solution, and it seems I have full functionality once again. Perhaps something has gone wrong in the NeuroDebian package once again?


The libdc1394 version has changed between Ubuntu 20.04 LTS based systems and Ubuntu 20.10 (based) systems like Pop!_OS 20.10. Psychtoolbox for Octave packages are individually built by NeuroDebian for each specific supported Linux distribution, but the Matlab Psychtoolbox just is a copy of what you get from us directly - the mex files built by myself for Matlab, currently on Ubuntu 18.04.5 LTS, “one size fits all”. So Screen.mexa64 for Matlab on Linux requires the libdc1394 from Ubuntu 20.04 and earlier, and some hacks are in place for Ubuntu 20.10, creating a symlink to fix up the system if this trouble is encountered. AssertOpenGL takes care of that, if executed. It gets automatically executed by our DownloadPsychtoolbox, UpdatePsychtoolbox, ... but not by NeuroDebian setup, probably an oversight of mine.

So probaby executing AssertOpenGL would do the trick. It would ask for your admin password and then create a symbolic filesystem link from the expected to the actually available

Once Ubuntu 22.04 LTS comes out in about a year, we will have to think of a less hacky way to deal with this, but i don’t have the time to deal with all non-LTS versions or other Linux variants as carefully. After all, time is money, and money is in short supply unless way more labs start buying our community memberships than do now.

It is true though that NeuroDebian is quite a bit behind lately with PTB updates. It is volunteer driven, and Yaroslav has a lot on his plate. The pandemic is also not helping…

Did you buy a System76 laptop? What model and specs? Feedback about well suited Linux laptops can be quite useful for others who are searching for a good machine. I would recommend avoiding the NVidia based offerings for use with PTB, but i think they now have not only Intel, but also AMD graphics based laptops in store?

As a european i don’t have any experience with them, but I recently half-listened to this interview with System76 wrt. the ‘Right to repair’ legislation in the US and their approach to building computers for longevity. Quite interesting and worthy of support, quite the opposite of what Apple is doing. Also an interesting backgound to the logistics of manufacturing and selling laptops, supply chains etc.:


Thanks for the thoughtful reply on such an old thread! I opened MATLAB with OpenGL enabled and was still running into the issues. But, for other users on 20.10 variants installing from DownloadPsychtoolbox seemed to work fine.

The System76 laptop was based on their Galago specs: Galago Pro - System76. We elected to use Pop!_OS per our institution’s request for encryption on portable devices, but they carry a Ubuntu 20.04 LTS version–which it sounds like you recommend for anyone reading this in the future.

I avoided the GTX 1650 option and went with Intel Iris Xe graphics as I saw the tales cautioning against NVIDIA. When I shopped around I did not notice any AMD graphics options.

The default processor seems to serve our purposes, but I’m curious to see how it holds up as we start collecting more data. RAM is easy to replace on laptops so we went with 8GB to start with, knowing we can upgrade in the future if needed.

I will have to listen to that interview as I work today, that sounds very interesting!

The new PTB beta, once NeuroDebian updates to it, also calls AssertOpenGL as part of calling PsychLinuxConfiguration, which is a call one should make after a NeuroDebian installation. This may take a while, as NeuroDebian is quite slow at the moment in picking up our new releases.

In any case, AssertOpenGL contains the automatic compatibility troubleshooting code to deal with Ubuntu 20.10 and later, so that would hopefully fix issues also on current NeuroDebian installs. In theory every PTB user script written by the book would call AssertOpenGL or even better the modern PsychDefaultSetup(1) or PsychDefaultSetup(2) as the first thing, so any such issues would get quickly dealt with. In practice, i’m sure that thanks to sloppiness, even some of our demos are missing those calls (“Do as i say, not do as i do” and all that…)

I don’t have any experience with Pop!_OS, but read good things about it. Given that my time is finite, I currently only develop and test against recent Ubuntu, and Raspbian for the RaspberryPi. But as far as i understand, Pop!_OS is derived from/based on Ubuntu, just customized and fine-tuned for System76’s machines and with a tweaked user interface, so it is probably compatible with the matching Ubuntu version for our purposes. So i guess Ubuntu 20.04 LTS and Pop 20.04 LTS would be pretty much the same for PTB, ditto for the 20.10 versions.

The Ubuntu LTS versions get more exhaustive testing by myself, and usually somewhat ahead of their public release, to minimize or avoid showstopper bugs. I think so far this worked well for the last 13 years. The non-LTS versions get some light testing, if and when time permits. E.g., Ubuntu 21.04 will be released today, and so far i haven’t found the time to even test it on a single machine. Single major components like the Linux 5.11 kernel, X-Server or Mesa received some light spot-testing at some point over the last couple of months though, so it will probably be fine. How much time i can allocate for these kinds of important maintenance and testing is directly dependent on funding by the community. That’s one reason why we started the community membership offerings with priority support, to give labs a rather affordable and simple way to financially contribute to the future quality and well-being of PTB, and especially in combination with Linux, as far as demanding use cases are concerned. So far the participation of labs is underwhelming, so we’ll have to see how much long term thinking is present out there.

Intel instead of NVidia was certainly a good choice for timing precision and likely for quality of life. Iris Xe is a very recent Intel gpu though, and these things usually need time to mature, so this is one case where it can be advantageous to stick to the latest Ubuntu (or PopOS i guess) version to have convenient access to the most recent graphics and display drivers, for the latest fine-tuning, performance enhancements, bug fixes. Well, or using a third party ppa to keep track of the latest drivers when sticking to the LTS releases.


As i see, they do use dual-channel RAM, so that’s good for optimal memory performance.


I’m on ubuntu 20.04 LTS, and I get the same error - having istalled PTB from neurodebian.
trying to install libdc I got

libdc1394-22 is already the newest version (2.2.5-2.1)

just typing Screen into matlab gives again:

Invalid MEX-file ‘/usr/share/psychtoolbox-3/PsychBasic/Screen.mexa64’: cannot open shared object file: No such file or directory

and running AssertOpenGL gives:


A very simple test call to the Screen() MEX file failed in AssertOpenGL, indicating
that either Screen is totally dysfunctional, or you are trying to run your script on
a system without Psychtoolbox-3 properly installed - or not installed at all.

The library seems to exist in a suitable version, but something related to that library
is borked. This needs some human help from a capable human brain, sorry.

Screen() on GNU/Linux needs the following 3rd party libraries
to function correctly. If you get “Invalid MEX file errors”,
or similar fatal error messages, check if these are installed on your
system and if they are missing, install them via your system specific
software management tools (e.g., apt install on Debian or Ubuntu).
On a Debian/Ubuntu based system, you may get the system to install all these
required dependencies for you by issuing the following commmand in a terminal:

sudo apt build-dep psychtoolbox-3

  • GStreamer multimedia framework: At least version 1.8.0 of the core runtime and the gstreamer-base plugins.
    For optimal performance and the full set of features, use the latest available versions. E.g., for optimal HDR
    movie playback GStreamer 1.18 would be needed, although it can be made to work less conveniently with v1.16.
    You may need to install additional packages to playback all common audio and video file formats.
    See “help GStreamer” for more info.

  • libusb-1.0 USB low-level access library.

  • libdc1394 IEEE-1394 Firewire and USB-Vision IIDC video capture library. on systems older than Ubuntu 20.04-LTS, for later systems.

Screen() does not work. Read all preceeding and following output as well as “help AssertOpenGL” for more info.
A first diagnostic test would be to simply type ‘Screen’ in your Matlab/Octave console and check what its output is.

The returned error message by Matlab/Octave was:
Last Error: Invalid MEX-file ‘/usr/share/psychtoolbox-3/PsychBasic/Screen.mexa64’: cannot open shared object file: No such file or directory (MATLAB:mex:ErrInvalidMEXFile)

Any help would be greatly appreciated…

Hmm. Seems a packaging mistake was made by NeuroDebian for the current matlab-psychtoolbox-3 package. While the Octave version octave-psychtoolbox-3 encodes the correct dependency of libdc1394-25, the Matlab version encodes the outdated libdc1394-22. I’ll have to contact Yaroslav about this.

Either installing sudo apt install octave-psychtoolbox-3 for a parallel install of the Psychtoolbox for Octave, or sudo apt install libdc1394-25 should hopefully resolve the missing dependency. Or you could sudo apt install libdc1394-dev as yet another variant.

Another way to get most (all?) dependencies installed, also for use with Psychtoolbox from our website is to sudo apt build-dep psychtoolbox-3, as a catch-all.


NeuroDebian say they have fixed the bug and new packages are distributing to the mirror servers now, so checking for and applying a new update might be the most easy solution. Could take a couple of hours, depending on where you are located.

Amazing, it works!

Best way to thank us is buying a paid support memebership to contribute to PTB’s maintenance (help PsychPaidSupportAndServices) and taking part in our currently running user survey, as mentioned in one of the sticky posts at the top of this website.