Error when running compiled application: Undefined function ’webcammex'

23 views (last 30 days)
I am using the Application Compiler to deploy my Matlab program (2015b). The packaging is successful but when I run it I’m getting the error:
Undefined function or variable 'webcammex'.
Error in matlab.webcam.internal.Utility.enumerateWebcams
Error in webcamlist (line 25)
Error in ...
MATLAB:UndefinedFunction
Does anyone know what’s causing this and what file I need to add when I compile the application?
Thanks.
  3 Comments
Bernard Rivera Camacho
Bernard Rivera Camacho on 12 Mar 2020
Hello Rebecca
I have the same error I can run the Code in the Matlab application but not in the Stand alone application.
do you have a hint that i could follow?
Matlab 2014b 32 bit

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 15 May 2020
I had this problem today and will show you how to fix it. When it hit
webcamlist
it threw the error: "Unrecognized function or variable 'webcammex'." Normally that command in the development environment would give something like this:
>> webcamlist
ans =
1×1 cell array
{'Integrated Webcam'}
So the webcam worked in development environment but not in the compiled standalone Windows executable, even though I had the required Support Package installed. Now I will tell you how to fix it.
First make sure you have the support package installed by going to the Home tab of the tool ribbon and selecting Add-Ons\Get Add-Ons.
Install the "MATLAB Support Package for USB Webcams".
Now, here's the unexpected thing (and why I had to call tech support). Unlike toolbox functions, Support Package functions are not automatically found and included/built-in to your function when you compile it. They need to be specifically added in with the '-a' option of the mcc function/command. So here is essentially how we got it to work (finally, after 20 minutes of trying different things with tech support):
mFileName = 'my_webcam_app.m'; % or whatever it's called. Change to match your m-file's name.
outputFolder = 'C:\My MATLAB Executables'; % Or wherever you want the compiled "my_webcam_app.exe" to go.
fprintf('Beginning compile of %s application at %s ...\n', mFileName, datestr(now));
tic;
% Now we're ready to compile.
% But first, make sure you change R2020a in the line below to whatever release year you're using.
mcc('-m', mFileName, '-d', outputFolder, '-a', 'C:\ProgramData\MATLAB\SupportPackages\R2020a\toolbox\matlab\webcam\supportpackages');
% Done compiling. Tell developer that we're done, and how long it took to compile.
elapsedSeconds = toc;
minutes = int32(floor(elapsedSeconds / 60));
seconds = elapsedSeconds - 60 * double(minutes);
message = sprintf('It is done compiling %s at %s. It took %d minutes and %.1f seconds.\n', mFileName, datestr(now), minutes, seconds);
fprintf('%s\n', message);
msgboxw(message);
For more information, here is the documentation link I got from Tech support:
This is the resource I mentioned that describes how to include a support package for compiled applications:
I hope this helps you get your compiled webcam application working. If it was helpful, then please click the Vote button up at the top of my Answer.

More Answers (0)

Categories

Find more on Application Deployment in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!