Invalid Mex File: Gateway Function is missing in compiled app

20 views (last 30 days)
I've built an app in appdesigner that uses some C++ code and Mex. I then compiled this app and sent it to some users using Windows 10. It works fine on my computer and at least one of my users is able to get it to work, but another user is getting this error when she tries to run it:
Invalid Mex-file 'C:\Users\username\appData\Local...\BackgroundSubtractorOCV.mexw64' : Gateway function is missing.
I'm using a background subtractor script from openCV provided by Matlab.
None of the answers I've seen around this issue online have helped. Thanks for any help you can provide.
  1 Comment
Einar Heiberg
Einar Heiberg on 14 Jul 2021
I have also recently got the same problem. Works on a lot of machines and then suddenly on one machine it does not work. Tried to upgrade Microsoft Visual Studio libraries on that machine, but it did not help.

Sign in to comment.

Answers (1)

Namnendra
Namnendra on 27 Apr 2023
Edited: Namnendra on 27 Apr 2023
Hey Aaron,
This error message typically occurs when the Mex-file is not compiled correctly or is missing the gateway function that is required to communicate between MATLAB and the C++ code. This can happen if the user's computer does not have the required libraries or if the Mex-file was not compiled for their specific architecture.
To resolve this issue, you can try the following steps:
1. Make sure that the user's computer has the required libraries and dependencies for the OpenCV background subtractor script. You can check the MATLAB documentation for the specific requirements.
2. Recompile the Mex-file on the user's computer. To do this, you can use the `mex` function in MATLAB to compile the C++ code into a Mex-file. Make sure to compile the Mex-file using the same architecture as the user's computer (e.g., 64-bit or 32-bit).
3. Check that the gateway function is present in the Mex-file. You can use the `whos` command in MATLAB to check if the gateway function is present in the Mex-file.
4. Make sure that the Mex-file is included in the MATLAB path on the user's computer. You can use the `addpath` function in MATLAB to add the path to the Mex-file to the MATLAB path.
If these steps do not resolve the issue, you may need to check if there are any compatibility issues between the OpenCV version used by the user and the version used to compile the Mex-file.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!