I had this problem today and will show you how to fix it. When it hit
it threw the error: "Unrecognized function or variable 'webcammex'." Normally that command in the development environment would give something like this:
1×1 cell array
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';
outputFolder = 'C:\My MATLAB Executables';
fprintf('Beginning compile of %s application at %s ...\n', mFileName, datestr(now));
mcc('-m', mFileName, '-d', outputFolder, '-a', 'C:\ProgramData\MATLAB\SupportPackages\R2020a\toolbox\matlab\webcam\supportpackages');
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);
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.