How to render webfigure on a 64-bit Windows platform?
MATLAB: Render WebFigure in Microsoft Visual Studio on Windows 64-bit System
64bitiisMATLAB Compiler SDKwebfigurewebfiguresservice
Related Solutions
To create a Visual Studio solution (.sln) file that will build a ".mex" file for use in MATLAB/Simulink based on existing source code, please do the following:
1) Open Visual Studio, and create a new project by selecting "File"->"New"->"Project from existing code"
2) Choose "Visual C++" as the type of project.
3) You may choose any project location that you like, but the project name should match the name of the resulting S-function. That means that the project is intended to produce <project name>.mexw<32|64>, and that the source code includes the preprocessor directive: "#define S_FUNCTION_NAME <project name>"
4) Using the "Add" button, select all of the user-defined source files and add them to the project.
5) In the next pane, select "Use Visual Studio" as the method for building the project, and for the "Project Type" select "Dynamically Linked Library (DLL) Project". Click 'Next'.
6) For the "Preprocessor definitions" field add
MATLAB_MEX_FILE
7) For the "Include Search Paths" field, add
"<MATLABROOT>\simulink\include"
and
"<MATLABROOT>\extern\include"
(including quotes) where <MATLABROOT> is the absolute path to the MATLAB installation.
8) Finish creating the project
9) Right-click on the newly-created project in the Solution Explorer and select "Properties" and make the following changes in the dialog that appears:
10) Click the "Configuration Manager" button, and in the dialog that appears open the "Active solution platform" drop-down menu. If you want to create an S-Function for 64-bit MATLAB, make sure "x64" is selected. If it is available, select it. If not, select "<new...>" and select "x64" from the dialog that appears. If the "Platform" for your project in the subwindow below is "Win32" change it to "x64" as well. If "x64" is not an option, create it by selecting "<new>". When the new window opens, select "x64" under "New platform" and unclick "Create new solution platform". Click "OK" and "Close" to apply these changes to the Property window.
11) In the "Linker" pane, select the "General" section, and edit the file extension in the "Output File" section, changing it from ".dll" to ".mexw32" or ".mexw64". (This is why the project name has to match the S-function name, ensuring that the generated ".mex" file name matches the "S_FUNCTION_NAME" defined in the source code.)
12) In the "Linker" pane, select the "Input" section and add to "Additional dependencies" section, and add the following(including quotes, and expanding <MATLABROOT> to be the MATLAB installation directory):
"<MATLABROOT>\extern\lib\win64\microsoft\libmx.lib" "<MATLABROOT>\extern\lib\win64\microsoft\libmat.lib" "<MATLABROOT>\extern\lib\win64\microsoft\libmex.lib"
(If you are creating an S-Function for 32-bit MATLAB, please replace win64 by win32)
13) In the "General" pane, set "Platform Toolset" to "Windows7.1SDK".
14) Click "Apply" and close the dialog box.
15) Select "Project"->"Add"->"New Item".
16) If you have a "Module-Definition file" option, select "Module-Definition file" from the GUI, give the file a name, and then click "Add".
16a) Edit the newly-created module-definition file to be the following, where <s-function name> is the project/S-function name, and <extension> is the appropriate extension for the target architecture (e.g. "mexw32" or "mexw64"):
LIBRARY"<s-function name>.<mex extension>" EXPORTS mexFunction
17) If you do not have a "Module-Definition file" option, you would need to create this file outside of Visual Studio and import it. Create a text file with the following information inside it:
LIBRARY"<s-function name>.<mex extension>" EXPORTS mexFunction
Save the file with a name to the folder that contains the Visual Studio Solution.
17a) Change the extension from ".txt" to ".def". Inside Visual Studio, select "Project"->"Add"->"Existing Item" and select the .DEF file.
At this point, you should be able to select the "build" option from the menus to create a ".mex" file that will work with Simulink.
Please note: For distributing S-functions created this way, it is necessary to use the "release" output from Visual Studio, not the "debug" output. For each mode selected you would need to make sure the steps starting from step 9 are set in that mode. In some cases, the "debug" output will require debuggable versions of standard DLLs, which could clash with normal versions already loaded by Simulink.
Attached is a ZIP file that contains the an example Visual Studio Solution and files configured for building S-function MEX according to the instructions above. The ZIP file contains the following:
1) "subsystem_sfcn_rtw" folder containing the C and H files for the S-function
2) "Project" folder containing the Visual Studio files.
The general steps for manually installing the WebFigureService on 64-bit servers are given in the "Deploying a MATLAB Figure Over the Web Using WebFigures" -> "Advanced Configuration of a WebFigure" section in the MATLAB Builder NE documentation. A short summary is also given here:
1. Copy WebFiguresService.dll to your Web Application's "bin" directory.
2. Add the following to your Web Application's 'Web.config system.web' section:
<httpHandlers> <add path="__WebFigures.ashx" verb="GET" type="MathWorks.MATLAB.NET.WebFigures.Service.Handlers.Factories.Http.WebFigureHttpHandlerFactory" validate="false" /></httpHandlers>
When working with .NET Framework 4.0 on IIS 7.5 there are two more configuration settings which you need to take into account, in IIS Manager:
1. Under the server wide "ISAPI and CGI Restrictions" settings you need to enable "Allow extension path to execute" for the ASP.NET v4.0.XXXX version which you are using.
2. The Application Pool which is used by your Web Application should use "Managed pipeline mode" = "Classic". This means that if your server already has an "ASP.NET v4.0 Classic" Pool, you could assign your Application to this. Or if you want to create your own Pool, make sure you set "Managed pipeline mode" correctly to "Classic".
Related Question
- MATLAB 7.10 (R2010a) returns Null when using getElementByID
- How to change the default Web Server port ‘8080’ for HTTP in Polyspace
- How to build a C++ program using MATLAB Engine in Visual Studio
- Writing Web service in MATLAB
- How to change the current GCC/G++ version to a supported one
- Does MATLAB not properly connect to the web service
- How to deploy a Simulink model over the web using MATLAB Compiler 4.5 (R2006b)
- How to update Web App Server account credentials
Best Answer