Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

Technical Solutions

Can I create a CGI executable which calls a shared library using the MATLAB Compiler to deploy my application on the web?


Date Last Modified: 24 Jun 2008
Solution ID:   1-2YVMOV
Product:   MATLABĀ® Compiler™
Reported in Release:   No Release
Platform:   All Platforms
Operating System:   All OS
 

Subject:

Can I create a CGI executable which calls a shared library using the MATLAB Compiler to deploy my application on the web?

Problem Description:

I want to deploy my application on the web. I want to compile my MATLAB application in to a shared library and write the CGI application in C.

Solution:

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 M-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:
http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f2-972343.html#f2-1000836

 

Related Documents/Files:

 

Related Solutions:

  Provide feedback to help us improve this solution!
Contact support
E-mail this page
Print this page