• How do I set up a Microsoft Visual Studio project to work with MATLAB Compiler 4.0?


    山城棒棒儿军 @ 2004-10-08 20:10

    http://www.mathworks.com/support/solutions/data/1-OQHIV.html?solution=1-OQHIV

    Technical Solutions
    Solution Number: 1-OQHIV

    Date Last Modified: 28 Sep 2004 Product:   MATLAB® Compiler
    Reported in Release:   R14
    Fixed in Release:    
    Platform:   Windows
    Operating System:   Windows Any



    Subject:
    How do I set up a Microsoft Visual Studio project to work with MATLAB Compiler 4.0?


    Problem Description
    I am using Microsoft Visual Studio with the MATLAB Compiler. How can determine which libraries and directories to include in my project?


    Solution:
    By looking at the verbose output generated by compiling a simple example from MATLAB, you can determine which libraries and directories to include in your project.

    The following example shows how to determine the libraries and paths needed for a Microsoft Visual Studio 7.1 project by compiling the hello.m demo, which can be found in the following directory:

    $MATLAB\extern\examples\compiler
    (where $MATLAB = the MATLAB root directory on your machine)


    1. Ensure that the Compiler has been configured using the "mbuild -setup" command.

    At the MATLAB command prompt, issue the following command:


    mbuild -setup



    Follow the prompts to install your compiler.

    2. Set up a temporary directory to compile the hello.m example, and change into that directory.

    At the MATLAB command prompt, issue the following commands:


    tempDir = fullfile(matlabroot,'work','hello_test');
    mkdir(tempDir);
    cd(tempDir);




    3. Using the verbose output flag ("-v"), compile the hello.m example into the temporary directory of Step 2.

    At the MATLAB command prompt, issue the following command:


    mcc('-m','-v',fullfile(matlabroot,'extern','examples','compiler','hello.m'),'-d',tempDir)



    You can test your compiled application by issuing the following command at the MATLAB command prompt:



    system(fullfile(tempDir,'hello.exe'));



    Step 4. Examine the verbose output to see what options are passed to the compiler.

    Among the output generated will be the following lines:




    --> "cl  -ID:\Applications\MATLAB7\work\hello_test -c -Zp8 -G5 -W3 -nologo
    /FoD:\Applications\MATLAB7\work\hello_test\hello_main.obj
    -ID:\Applications\MATLAB7\extern\include -ID:\Applications\MATLAB7\simulink\include
    -O2 -DNDEBUG D:\Applications\MATLAB7\work\hello_test\hello_main.c"

    --> "cl  -ID:\Applications\MATLAB7\work\hello_test -c -Zp8 -G5 -W3 -nologo
    /FoD:\Applications\MATLAB7\work\hello_test\hello_mcc_component_data.obj
    -ID:\Applications\MATLAB7\extern\include -ID:\Applications\MATLAB7\simulink\include
    -O2 -DNDEBUG D:\Applications\MATLAB7\work\hello_test\hello_mcc_component_data.c"

    --> "link "/out:D:\Applications\MATLAB7\work\hello_test\hello.exe" kernel32.lib
    user32.lib gdi32.lib advapi32.lib oleaut32.lib ole32.lib /LIBPATH:"D:\Applications\MATLAB7\extern\lib\win32\microsoft\msvc71" /nologo mclmcrrt.lib  
    @D:\Applications\MATLAB7\work\hello_test20_tmp.rsp "



    4a. Look for the compiler include directories.

    The include directories are contained in the lines beginning with "cl" and are denoted by "-I". The include directories that are not specific to the compiled application are the ones that should be added to your project. In this example, the following three include directories are specified.

    4a1. "D:\Applications\MATLAB7\work\hello_test"

    This directory does not need to be added to Microsoft Visual Studio project because the directory was specific to this application.

    4a2. " D:\Applications\MATLAB7\extern\include"

    This directory should be added to future Microsoft Visual Studio projects as an additional include directory.

    4a3. " D:\Applications\MATLAB7\simulink\include"

    This directory should not be added. The reason this include directory appears is because of a bug, as mentioned in Solution 1-O9PX9: Why do I receive a set_param Warning or Error when Using MATLAB Compiler 4.0?

    http://www.mathworks.com/support/solutions/data/1-O9PX9.html

    4b. Look for the linker library directories.

    The linker library directories are contained in the line beginning with "link " and are denoted by "/LIBPATH:". In this example, the following linker library directory is specified.

    4b1. "D:\Applications\MATLAB7\extern\lib\win32\microsoft\msvc71"

    This directory should be added to future Microsoft Visual Studio projects as an additional library directory.

    4c. Look for the additional MATLAB Component Runtimer (MCR) library dependency.

    The MATLAB Component Runtimer (MCR) library dependency is contained in the line beginning with "link " and is denoted by "/nologo"

    4c1. "mclmcrrt.lib"

    This library should be added to future Microsoft Visual Studio projects as an additional dependency.


    5. Add the directories and libraries of Step 4 to your Microsoft Visual Studio project.

    In MSVC 7.1, set the following properties:

    5a. C/C++ -> General (from Step 4a, above)

    -> Additional Include directory: D:\Applications\MATLAB7\extern\include

    -> Runtime library: Multi-threaded

    5b. Linker -> General (from Step 4b, above)

    -> Additional Library Directory: D:\Applications\MATLAB7\extern\lib\win32\microsoft\msvc71

    5c. Linker -> Input (from Step 4c, above)

    -> Additional dependencies: mclmcrrt.lib
  • 相关阅读:
    『计算机视觉』Mask-RCNN_推断网络其五:目标检测结果精炼
    『TensorFlow』高级高维切片gather_nd
    『计算机视觉』Mask-RCNN_推断网络其四:FPN和ROIAlign的耦合
    『计算机视觉』Mask-RCNN_推断网络其三:RPN锚框处理和Proposal生成
    『计算机视觉』Mask-RCNN_推断网络其二:基于ReNet101的FPN共享网络暨TensorFlow和Keras交互简介
    『计算机视觉』Mask-RCNN_推断网络其一:总览
    在ASP.NET MVC项目中使用React
    详解ABP框架的多租户
    .NET开发者如何愉快的进行微信公众号开发
    微软的R语言发行版本MRO及开发工具RTVS
  • 原文地址:https://www.cnblogs.com/yunbo/p/541241.html
Copyright © 2020-2023  润新知