Effacer les filtres
Effacer les filtres

Best practice for adding program path for programs intended for compiling

3 vues (au cours des 30 derniers jours)
Mikael Agopov
Mikael Agopov le 13 Août 2021
Réponse apportée : Rishav le 17 Avr 2024
My software for data analysis has grown to a fairly big size, and is split to several subdirectories,
like /MATLAB/Myprogram, /MATLAB/Myprogram/GUI
and some others. Normally, I just list the paths to startup.m,
path(path,'/MATLAB/Myprogram')
path(path,'/MATLAB/Myprogram/GUI')
and so on. This works fine, but when I compile the software (to be used with MRE), a bunch of warnings are created,
as this is considered bad programming practice for programs intended for compiling (I agree with that). However, the problem is that I HAVE NOT FOUND AN OBVIOUS ALTERNATIVE WAY of telling MATLAB where to find the functions and classes!
What would that be?

Réponses (1)

Rishav
Rishav le 17 Avr 2024
Hi Mikael,
I understand that you want to know the best practice to add the program path for programs intended for compilation.
Instead of dynamically adding paths at runtime, you can set up your paths statically before compilation. You can do this by organizing your code as suggested above and then using the 'mcc' command (MATLAB Compiler Command) with the '-a' option to explicitly add any additional files or folders that are not automatically included due to direct referencing in your code. For example:
mcc -m MyMainScript.m -a /path/to/additional/files
This tells the compiler explicitly about additional files or directories to include in the compilation.
You can also refer to the below mentioned documentation on mcc Comand Line Arguments:

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by