Filter löschen
Filter löschen

'mcc' command complains about "invalid directory" with R2022a

2 Ansichten (letzte 30 Tage)
Pratik Chachad
Pratik Chachad am 27 Jan. 2023
Beantwortet: Image Analyst am 27 Jan. 2023
I am trying to use the 'mcc command to compile a matalb file into a standalone application on 2022a linux version.
The command is as follows
mcc('-m',filename1, '-d', compileDir);
But I get an error saying "Invalid directory: /folder1/filename1.m/filename2.m" this error makes sense because my folder structure is as follows
My filename1.m uses a call to another function filename2.m but both of them are in the same folder1 as shown above.
How do I make my mcc command work so that it does not look for filename2.m under folder1/filename1.m/filename2.m but instead looks for filename2.m inside the same folder1 where filename1.m is located.

Antworten (1)

Image Analyst
Image Analyst am 27 Jan. 2023
Since you did not specify a folder for filename1.m and filename2.m, it will look in the current folder, which of course will exists. If those files are in the current folder, that will not throw an error.
So the next place to look is at compileDir, which is the folder where you want the compiled executable to be saved to after the compilation has completed successfully. And that is where we're seeing the problem. The folder almost certainly should not be "/folder1/filename1.m/filename2.m".
Somehow when you constructed the compileDir variable, you made it incorrectly. Somehow the filenames got in there instead of just the folder alone. So of course that folder does not exist. Take a look again at how you create compileDir. It should be something like
compileDir = '/folder/Compiled Output';
if ~isfolder(compileDir)
warningMessage = sprintf('Note: "%s" does not exist yet.\nI will create that folder now.', compileDir);
buttonText = questdlg(warningMessage, 'Continue?', 'OK - Continue', 'Quit', 'OK - Continue');
drawnow; % Refresh screen to get rid of dialog box remnants.
if strcmpi(buttonText, 'Quit')
or something like that.


Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by