{"id":269,"date":"2011-03-22T18:05:39","date_gmt":"2011-03-22T18:05:39","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2011\/03\/22\/interpreting-the-code-analyzers-deployment-messages\/"},"modified":"2018-11-04T20:00:49","modified_gmt":"2018-11-05T01:00:49","slug":"interpreting-the-code-analyzers-deployment-messages","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2011\/03\/22\/interpreting-the-code-analyzers-deployment-messages\/","title":{"rendered":"Interpreting the Code Analyzer&#8217;s Deployment Messages"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Guest blogger <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4660\">Peter Webb<\/a> returns with another in an <a href=\"https:\/\/blogs.mathworks.com\/loren\/category\/deployment\/\">occasional series<\/a> of postings about application deployment.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#2\">Unsupported MATLAB Features<\/a><\/li>\r\n         <li><a href=\"#3\">Unsupported Functions<\/a><\/li>\r\n         <li><a href=\"#4\">DEPLOYPRINT<\/a><\/li>\r\n         <li><a href=\"#5\">WEBFIGURE<\/a><\/li>\r\n         <li><a href=\"#6\">Functions with Unexpected Behavior<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>Previously, Jacob introduced the <a href=\"https:\/\/blogs.mathworks.com\/loren\/2011\/02\/24\/using-m-lint-to-help-write-deployable-code\/\">MATLAB code analyzer<\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/mlint.html\"><tt>mlint<\/tt><\/a>, which helps you write better code by notifying you of questionable constructs and opportunities for performance enhancement.\r\n      The code analyzer's messages are organized into categories, one of which is <i>deployment<\/i>. The deployment category contains 16 messages. Deployment messages are off by default; you <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_env\/brqxeeu-151.html#brw2b2w\">activate them<\/a> via <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_env\/brqxeeu-151.html#brw2bpr\">code analyzer preferences<\/a>. To help you make the best possible use of the feedback provided by the code analyzer, I'll use this week's posting to provide\r\n      an interpretation of each of its deployment messages. In the sections below, I quote code analyzer warning messages in <i>italics<\/i>.\r\n   <\/p>\r\n   <h3>Unsupported MATLAB Features<a name=\"2\"><\/a><\/h3>\r\n   <p>Some features of MATLAB do not work in deployed applications because of <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/06\/19\/writing-deployable-code\/\">differences<\/a> between the deployed environment and the MATLAB interactive environment. The MATLAB code analyzer warns about five such features:\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><i>MCC allows writing .m files, but they cannot be executed by the deployed application.<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>A MATLAB function may create another MATLAB function and then call it. For example, the <a href=\"https:\/\/www.mathworks.com\/products\/deep-learning.html\">Deep Learning Toolbox<\/a> uses this technique to train neural networks. A deployed application may create MATLAB functions on disk, but it cannot execute\r\n      them. Deployed applications <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/#2\">only execute<\/a> <i>encrypted<\/i> MATLAB functions and only <a href=\"https:\/\/www.mathworks.com\/products\/compiler\">MATLAB Compiler<\/a> can create encrypted functions for deployment (MATLAB Compiler itself cannot be deployed).\r\n   <\/p>\r\n   <p>Functions that create and then call MATLAB functions on disk cannot be deployed. If your code needs to create simple functions\r\n      at runtime, you may be able to use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_prog\/f4-70115.html\">anonymous functions<\/a> instead of creating new MATLAB function files.\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><i>MCC does not allow C++ files to be read directly using LOADLIBRARY.<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>When processing a C++ header file, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/loadlibrary.html\"><tt>loadlibrary<\/tt><\/a> creates new MATLAB function files. As discussed above, creating and then calling new MATLAB functions is a non-deployable\r\n      feature. As a result <tt>loadlibrary<\/tt> cannot be used with C++ headers in deployed applications. However, you can <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f2-972343.html\">deploy applications<\/a> that use MATLAB function prototypes with <tt>loadlibrary<\/tt>. (See the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f2-972343.html\">documentation for MATLAB Compiler<\/a>; search for \"loadlibrary\".)\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><i>MCC requires the program to assign a value to output argument <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq50068.png\">  name <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq97824.png\"> <\/i>.\r\n         <\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>When MATLAB Compiler processes a MATLAB function with outputs, it creates a wrapper function with output parameters. The generated\r\n      code requires that the output variables have valid MATLAB values when the function returns. MATLAB functions that do not assign\r\n      values to their outputs are likely to cause the program to crash.\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><i>MCC use of absolute file names is likely to fail.<\/i><\/li>\r\n         <li><i>MCC use of toolbox folder file names is likely to fail.<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>Deployed applications have a different view of the file system than applications running in interactive MATLAB. A deployed\r\n      application has a limited MATLAB path, and a different notion of the MATLAB root directory. A <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\">full discussion<\/a> of this issue is beyond the scope of this post but, generally speaking, it is best to use relative paths instead of absolute\r\n      paths, and to avoid references to files in a MATLAB installation. If you need access to a file in MATLAB in a deployed application,\r\n      include the file in the application with the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f0-985134.html\"><tt>-a<\/tt> switch<\/a> when creating it.\r\n   <\/p>\r\n   <h3>Unsupported Functions<a name=\"3\"><\/a><\/h3>\r\n   <p><i>MCC does not permit the <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq50068.png\">  function name <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq97824.png\">  function.<\/i><\/p>\r\n   <p>Certain MATLAB functions <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/#3\">cannot be deployed<\/a> because they rely on features of MATLAB that the deployed environment does not support. Avoid using these functions in code\r\n      you intend to deploy, or use the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/isdeployed.html\"><tt>isdeployed<\/tt><\/a> function to ensure your compiled program does not call these functions. The code analyzer issues warnings about five unsupported\r\n      functions:\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/addpath.html\">  <tt>addpath<\/tt><\/a>: The path a deployed application uses to look for executable functions is fixed when the deployed application is created,\r\n            and cannot be changed.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/help.html\"> <tt>help<\/tt><\/a>: The help database is too big to put in a deployed application. Besides, users of your application should not need help with\r\n            MATLAB functions, since your application encapsulates them.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/keyboard.html\"><tt>keyboard<\/tt><\/a>: The implementation of this function relies on the MATLAB desktop environment, and deployed applications do not have access\r\n            to the MATLAB desktop.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/printdlg.html\"><tt>printdlg<\/tt><\/a>: On Microsoft Windows platforms, you must use <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/11\/25\/printing-in-a-deployed-application\"><tt>deployprint<\/tt> instead of <tt>print<\/tt><\/a>. As a result, certain forms of <tt>printdlg<\/tt> cannot be deployed.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/savepath.html\"><tt>savepath<\/tt><\/a>: Deployed applications do not support saving and loading the MATLAB path. The MATLAB path is embedded into a deployed application\r\n            when it is created, and the path can't be changed (so there's no point in saving it).\r\n         <\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>DEPLOYPRINT<a name=\"4\"><\/a><\/h3>\r\n   <p><i>MCC prefers Windows applications to call DEPLOYPRINT instead of PRINT, but use PRINT when printing to a file.<\/i><\/p>\r\n   <p>On Microsoft Windows platforms, a deployed application generates printed output by creating a JPEG file and then sending that\r\n      file to printer. This mechanism is <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/11\/25\/printing-in-a-deployed-application\/#2\">very different<\/a> from the way MATLAB prints on Windows platforms. Deployed applications must use the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deployprint.html\"><tt>deployprint<\/tt><\/a> function on Microsoft Windows platforms.\r\n   <\/p>\r\n   <h3>WEBFIGURE<a name=\"5\"><\/a><\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><i>MCC requires that the first argument of WEBFIGURE not come from FIGURE(n).<\/i><\/li>\r\n         <li><i>MCC requires that the first argument of WEBFIGURE not come from FIGURE(n) (line number).<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>Deployed applications use the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/javabuilder\/ug\/brydmnl-3.html\"><tt>webfigure<\/tt><\/a> function to display graphics inside of a web browser. <tt>webfigure<\/tt> takes a single argument: the handle of a figure. Certain details of the implementation require that the figure's numerical\r\n      ID be automatically assigned by Handle Graphics rather than specified by the user. The code analyzer issues this <tt>webfigure<\/tt> warning when it detects code manually specifying figure IDs. For example:\r\n   <\/p><pre>f_bad = figure(1);\r\nwf = webfigure(f_bad);   % Warning generated<\/pre><pre>f_ok = figure;\r\nwf = webfigure(f_ok);   % No warning generated<\/pre><h3>Functions with Unexpected Behavior<a name=\"6\"><\/a><\/h3>\r\n   <p><i>MCC use of the <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq50068.png\">  function name <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/269\/InterpretCodeAnalyzer_eq97824.png\">  function is problematic.<\/i><\/p>\r\n   <p>The code analyzer generates warnings for the first two of these functions because they manipulate or rely on the program's\r\n      view of the file system, which is <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/#2\">is very different<\/a> in a deployed application. The third warning, about <tt>deployprint<\/tt>, only appears on UNIX systems. Deployed applications on UNIX systems print using <tt>print<\/tt> instead of <tt>deployprint<\/tt>.\r\n   <\/p>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/cd.html\"><tt>cd<\/tt><\/a>: Changing the current directory in a deployed application does not affect the order in which the application will search\r\n            directories for executable functions. In fact, the current directory is <b>never<\/b> searched for executable functions.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/matlabroot.html\"><tt>matlabroot<\/tt><\/a>: In a deployed application, <tt>matlabroot<\/tt> refers to the root of the installed MCR against which the application is running. An MCR installation is not a full MATLAB\r\n            installation; applications cannot rely on being able to find all of MATLAB's functions or data files in an MCR installation.\r\n         <\/li>\r\n         <li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deployprint.html\"><tt>deployprint<\/tt><\/a>: As noted above, applications deployed to UNIX systems use <tt>print<\/tt> instead of <tt>deployprint<\/tt>.\r\n         <\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p>How do you use the code analyzer? Do these error messages make sense? Would you like to see the code analyzer integrated with\r\n      <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deploytool.html\"><tt>deploytool<\/tt><\/a> or <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/mcc.html\"><tt>mcc<\/tt><\/a>? Let us know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=269#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_40d2b43ab10b4595bccf06a2bfd8f091() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='40d2b43ab10b4595bccf06a2bfd8f091 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 40d2b43ab10b4595bccf06a2bfd8f091';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Peter Webb';\r\n        copyright = 'Copyright 2011 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_40d2b43ab10b4595bccf06a2bfd8f091()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.11<br><\/p>\r\n<\/div>\r\n<!--\r\n40d2b43ab10b4595bccf06a2bfd8f091 ##### SOURCE BEGIN #####\r\n%% Interpreting the Code Analyzer's Deployment Messages\r\n% Guest blogger \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/4660 Peter Webb>\r\n% returns with another in an \r\n% <https:\/\/blogs.mathworks.com\/loren\/category\/deployment\/ occasional series>\r\n% of postings about application deployment. \r\n\r\n%%\r\n% Previously, Jacob introduced the\r\n% <https:\/\/blogs.mathworks.com\/loren\/2011\/02\/24\/using-m-lint-to-help-write-deployable-code\/\r\n% MATLAB code analyzer>,\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/mlint.html |mlint|>, which\r\n% helps you write better code by notifying you of questionable constructs\r\n% and opportunities for performance enhancement. The code analyzer's\r\n% messages are organized into categories, one of which is _deployment_. The\r\n% deployment category contains 16 messages. Deployment messages are off by\r\n% default; you\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_env\/brqxeeu-151.html#brw2b2w\r\n% activate them> via\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_env\/brqxeeu-151.html#brw2bpr\r\n% code analyzer preferences>. To help you make the best possible use of the\r\n% feedback provided by the code analyzer, I'll use this week's posting to\r\n% provide an interpretation of each of its deployment messages. In the\r\n% sections below, I quote code analyzer warning messages in _italics_.\r\n\r\n%% Unsupported MATLAB Features\r\n% Some features of MATLAB do not work in deployed applications because of\r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/06\/19\/writing-deployable-code\/\r\n% differences> between the deployed environment and the MATLAB interactive\r\n% environment. The MATLAB code analyzer warns about five such features:\r\n%\r\n% * _MCC allows writing .m files, but they cannot be executed by the\r\n% deployed application._\r\n%\r\n% A MATLAB function may create another MATLAB\r\n% function and then call it. For example, the\r\n% <https:\/\/www.mathworks.com\/products\/deep-learning.html Deep Learning Toolbox> uses\r\n% this technique to train neural networks. A deployed application may\r\n% create MATLAB functions on disk, but it cannot execute\r\n% them. Deployed applications \r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/#2 only execute>\r\n% _encrypted_ MATLAB functions and only\r\n% <https:\/\/www.mathworks.com\/products\/compiler MATLAB Compiler>\r\n% can create encrypted functions for deployment\r\n% (MATLAB Compiler itself cannot be deployed). \r\n%\r\n% Functions that create and then \r\n% call MATLAB functions on disk cannot be deployed. If your code needs to \r\n% create simple functions at runtime, you may be able to use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_prog\/f4-70115.html \r\n% anonymous functions> instead of creating new MATLAB function files. \r\n%\r\n% * _MCC does not allow C++ files to be read directly using LOADLIBRARY._\r\n%\r\n% When processing a C++ header file, \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/loadlibrary.html\r\n% |loadlibrary|> creates new MATLAB \r\n% function files. As discussed above, creating and then calling new MATLAB\r\n% functions is a non-deployable feature. As a result |loadlibrary| cannot\r\n% be used with C++ headers in deployed applications. However, you can\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f2-972343.html\r\n% deploy applications> that use MATLAB function prototypes with\r\n% |loadlibrary|. (See the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f2-972343.html \r\n% documentation for MATLAB Compiler>; search for \"loadlibrary\".)\r\n%\r\n% * _MCC requires the program to assign a value to output argument $<$ name\r\n% $>$_.\r\n%\r\n% When MATLAB Compiler processes a MATLAB function with outputs, it\r\n% creates a wrapper function with output parameters. The generated code\r\n% requires that the output variables have valid\r\n% MATLAB values when the function returns. MATLAB functions that do not\r\n% assign values to their outputs are likely to cause the program to crash.\r\n%\r\n% * _MCC use of absolute file names is likely to fail._ \r\n% * _MCC use of toolbox folder file names is likely to fail._\r\n%\r\n% Deployed applications have a different view of the file system than\r\n% applications running in interactive MATLAB. A deployed application has a\r\n% limited MATLAB path, and a different notion of the MATLAB root directory.\r\n% A <https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications \r\n% full discussion> of this issue is beyond the scope of this post but,\r\n% generally speaking, it is best to use relative paths instead of absolute\r\n% paths, and to avoid references to files in a MATLAB installation. If you\r\n% need access to a file in MATLAB in a deployed application, include the\r\n% file in the application with the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/f0-985134.html \r\n% |-a| switch> when creating it.\r\n%\r\n\r\n%% Unsupported Functions \r\n%\r\n% _MCC does not permit the $<$ function name $>$ function._\r\n%\r\n% Certain MATLAB functions \r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/#3 \r\n% cannot be deployed> because they rely on\r\n% features of MATLAB that the deployed environment does not support. Avoid\r\n% using these functions in code you intend to deploy, or use the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/isdeployed.html\r\n% |isdeployed|> function to ensure your compiled program does not call these\r\n% functions. The code analyzer issues warnings about five unsupported\r\n% functions:\r\n%\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/addpath.html\r\n%   |addpath|>: The path a deployed application uses to look for executable\r\n% functions is fixed when the deployed application is created, and cannot\r\n% be changed.\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/help.html \r\n%  |help|>: The help database is too big to put in a deployed application.\r\n% Besides, users of your application should not need help with MATLAB\r\n% functions, since your application encapsulates them.\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/keyboard.html \r\n% |keyboard|>: The implementation of this function relies on the MATLAB\r\n% desktop environment, and deployed applications do not have access to the\r\n% MATLAB desktop.\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/printdlg.html\r\n% |printdlg|>: On Microsoft Windows platforms, you must use \r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/11\/25\/printing-in-a-deployed-application \r\n% |deployprint| instead of |print|>. As a result, certain forms of\r\n% |printdlg| cannot be deployed.\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/savepath.html \r\n% |savepath|>: Deployed applications do not support saving and loading the\r\n% MATLAB path. The MATLAB path is embedded into a deployed application when\r\n% it is created, and the path can't be changed (so there's no point in \r\n% saving it).\r\n% \r\n\r\n%% DEPLOYPRINT\r\n%\r\n% _MCC prefers Windows applications to call DEPLOYPRINT instead of PRINT,\r\n% but use PRINT when printing to a file._\r\n% \r\n% On Microsoft Windows platforms, a deployed application generates printed\r\n% output by creating a JPEG file and then sending that file to\r\n% printer. This mechanism is\r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/11\/25\/printing-in-a-deployed-application\/#2 \r\n% very different> from the way MATLAB prints on Windows platforms. Deployed\r\n% applications must use the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deployprint.html \r\n% |deployprint|> function on Microsoft Windows\r\n% platforms.\r\n\r\n%% WEBFIGURE\r\n%\r\n% * _MCC requires that the first argument of WEBFIGURE not come from\r\n% FIGURE(n)._\r\n% * _MCC requires that the first argument of WEBFIGURE not come from\r\n% FIGURE(n) (line number)._\r\n%\r\n% Deployed applications use the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/javabuilder\/ug\/brydmnl-3.html \r\n% |webfigure|> function to display graphics\r\n% inside of a web browser. |webfigure| takes a single argument: the handle\r\n% of a figure. Certain details of the implementation require that the\r\n% figure's numerical ID be automatically assigned by Handle Graphics rather\r\n% than specified by the user. The code analyzer issues this |webfigure| \r\n% warning when it detects code manually specifying figure IDs. For example:\r\n%  \r\n%  f_bad = figure(1);\r\n%  wf = webfigure(f_bad);   % Warning generated\r\n%\r\n%  f_ok = figure;\r\n%  wf = webfigure(f_ok);   % No warning generated\r\n\r\n%% Functions with Unexpected Behavior\r\n%\r\n% _MCC use of the $<$ function name $>$ function is problematic._\r\n%\r\n% The code analyzer generates warnings for the first two of these functions because\r\n% they manipulate or rely on the program's view of the file system, which\r\n% is\r\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/#2\r\n% is very different> in a deployed application. The third warning, about\r\n% |deployprint|, only appears on UNIX systems. Deployed applications\r\n% on UNIX systems print using |print| instead of |deployprint|.\r\n%\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/cd.html \r\n% |cd|>: Changing the current directory in a deployed application does not\r\n% affect the order in which the application will search directories for\r\n% executable functions. In fact, the current directory is *never* searched\r\n% for executable functions. \r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/matlabroot.html \r\n% |matlabroot|>: In a deployed application, |matlabroot| refers to the\r\n% root of the installed MCR against which the application is running. An\r\n% MCR installation is not a full MATLAB installation; applications cannot\r\n% rely on being able to find all of MATLAB's functions or data files in an\r\n% MCR installation.\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deployprint.html  \r\n% |deployprint|>: As noted above, applications deployed to UNIX systems\r\n% use |print| instead of |deployprint|.\r\n%\r\n% How do you use the code analyzer? Do these error messages make sense? \r\n% Would you like to see the code analyzer integrated with \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/deploytool.html\r\n% |deploytool|> or <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/compiler\/mcc.html\r\n% |mcc|>? Let us know <https:\/\/blogs.mathworks.com\/loren\/?p=269#respond here>.\r\n\r\n\r\n\r\n##### SOURCE END ##### 40d2b43ab10b4595bccf06a2bfd8f091\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Guest blogger Peter Webb returns with another in an occasional series of postings about application deployment.\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n   ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2011\/03\/22\/interpreting-the-code-analyzers-deployment-messages\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/269"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":3128,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/269\/revisions\/3128"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}