Using MATLAB Compiler you can create a shared library which can be called from an executable written in C. This executable can be called by your Web server using the Common Gateway Interface (CGI).
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_Library.zip which can be downloaded from the bottom of this page. Perform the following steps to compile and run this example:
1. Compile the MATLAB file into a shared library. This can be done with the following command in MATLAB:
mcc -B csharedlib:libmymagic mymagic.m
2. Compile the C-file into an EXE-file which links to the library created in step 1. This can be done with the following command in MATLAB:
mbuild magicsquare.c libmymagic.lib
3. Copy HTML file to the Web server and place them in a directory with the proper permissions. Consult your Web server documentation for how to do this.
4. Copy the DLL, 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.
5. Install the MCR on the web server. For more information, see the "Deployment Process" section in the documentation by following the link at the bottom of this page.
6. Execute the application for the first time from the web server system itself in order to force the CTF-archive extraction.
7. 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 shared libraries, see the MATLAB Compiler documentation and C shared library example: