Is it possible to create a standalone CGI executable to deploy my application on the web using the MATLAB Compiler?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
I want to deploy my application on the Web. I want to write all my code in MATLAB and compile it with the MATLAB Compiler.
Accepted Answer
Using MATLAB Compiler you can create a standalone executable which can be called by your web server using the Common Gateway Interface (CGI).
A CGI program or script outputs HTML by printing it to the screen (stdout). Input to a CGI program is through the environment variable "QUERY_STRING". By using the MATLAB functions GETENV and FPRINTF you can create a simple CGI program.
Before attempting the following, you should verify that you have configured your web server properly in order to run CGI programs, and that you are able to execute a CGI program that is independent of MATLAB. Consult your web server documentation for how to do this.
An example has been created which demonstrates how to do this. The files for this example are located in the file CGI_Standalone.zip. The download link is present at the bottom of this page. Perform the following steps to compile and run this example:
1. Compile the MATLAB file into a standalone application. This can be done with the following command in MATLAB:
mcc -m mycgimagic.m
2. Copy the HTML file to the web server and place it in a directory with the proper permissions. Consult your web server documentation for how to do this.
3. Copy the EXE and CTF files to the web server and place them in the "/cgi-bin" directory of your website. You will need to configure the web server to have the proper permissions to be able to execute the EXE-file. Consult your web server documentation for how to do this.
4. Install the MCR on the web server.
5. Execute the EXE-file for the first time from the web server system itself in order to force the CTF-archive extraction.
6. Load the HTML-file in a web browser from the remote computer and submit the form to execute the CGI program.
For more information on standalone applications, see the MATLAB Compiler documentation and C standalone application target example.
7 Comments
Richa Gupta
on 25 Apr 2016
Edited: Richa Gupta
on 25 Apr 2016
Aman, please contact MathWorks Technical Support.
The link to download the example CGI_Standalone.zip seems to be missing. At least it's not visible from my browser.
"The files for this example are located in the file CGI_Standalone.zip. The download link is present at the bottom of this page."
Yes again another TMW solution where the attached files are missing
Neil, please contact MathWorks Technical Support.
(Answers dev) Attachment has been added.
CGI_Standalone.zip is a zip file of 2 KB
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
See Also
MathWorks Support
on 10 Sep 2012
on 22 Feb 2017
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)