How to compile a MATLAB Engine application in Microsoft Visual Studio

To compile a MATLAB engine application in the Microsoft Visual Studio 9.0 (2008) or Microsoft Visual Studio 10.0 (2010) environments, perform the steps outlined below:

1. Open Microsoft Visual Studio and select

File->New->Project

and then select:

Visual C++ -> General -> Empty Project

Following this, enter the name of the project and its location in the indicated text areas and click OK.

2. Right-click on the SOURCE FILES folder in the SOLUTION EXPLORER and click Add -> "New Item...". Choose "C++ file (.cpp)", enter the name of the file as enginedemo.cpp. Click OK.

3. Copy the code from the source file: engwindemo.c, and paste it into this file enginedemo.cpp. The file engwindemo.c may be obtained from the following location:

 $MATLABROOT/extern/examples/eng_mat

where $MATLABROOT is the MATLAB root directory, and may be determined by entering the command:

matlabroot

at the MATLAB command prompt.

4. Right click on the project name and select PROPERTIES in the solution explorer to open the project properties. Once this window has opened, make the following changes:

a. Under C/C++ General, add the following directory to the field ADDITIONAL INCLUDE DIRECTORIES:

$MATLABROOT\extern\include

b. Under C/C++ Precompiled Headers, select "Not Using Precompiled Headers".

c. Under Linker General, add the directory to the field ADDITIONAL LIBRARY DIRECTORIES:

(For 32-bit Windows)

$MATLABROOT\extern\lib\win32\microsoft

(For 64-bit Windows)

$MATLABROOT\extern\lib\win64\microsoft

d. Under Configuration Properties ->Debugging

Add the following Target path in the Environment:

(for 32 bit MATLAB)

PATH=$matlabroot\bin\win32

(for 64-bit MATLAB)

PATH=$matlabroot\bin\win64

7. Under Linker Input, add the following names to the field marked ADDITIONAL DEPENDENCIES:

libmx.lib

libmat.lib

libeng.lib

8. If compiling on 64-bit Windows, change the target to x64 as mentioned on the following link:

http://msdn2.microsoft.com/en-us/library/9yb4317s(VS.80).aspx

You should now be able to build the executable.

9. Make sure that the following directory is in the PATH:

(For 32-bit Windows)

$MATLABROOT\bin\win32

(For 64-bit Windows)

$MATLABROOT\bin\win64

To do this, check the Windows system path by clicking on Start -> Right click on Computer -> Properties -> Advanced System Settings -> Environment variables -> System Variables -> Open "Path" for editing.

Note: If the machine has more than one MATLAB installed, the directory for the target platform must be ahead of any other MATLAB directory (for instance, when compiling a 64-bit application, the directory in the MATLAB 64-bit installation must be the first one on the PATH).

10. Build and execute the application.

时间: 2024-11-06 23:43:15

How to compile a MATLAB Engine application in Microsoft Visual Studio的相关文章

How To Compile Qt with Visual Studio 2010

This post is a step-by-step guide on how to compile Qt 4.x.x with MSVC 2010. Although we use Qt 4.7.1 as an example (for historical reasons), you can also find suggestions on building newer versions of Qt by MSVC 2012 and even by Intel Compiler for b

Visual Studio "The application can not start"

在电脑异常关机导致运行Visual Studio时弹出提示“The application can not start”,可以尝试一下下面的方法(红色字体部分以实际路径为准): 1. 找到 F:\Users\Viki\Documents\Visual Studio 2012下的Setting文件夹,删除 2. 打开命令行工具输入 "M:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv" /resetuserda

Visual Studio Create Setup project to deploy web application in IIS

Introduction: In this article I will explain how to create setup file in visual studio 2008/2010 to deploy web application file directly in IIS or in client machine or how to place web application folder in c:\\inetpub\wwwroot folder by running setup

在Visual Studio中开发Matlab mex文件,生成mexw64/mexw32

csunking贡献,2015-9-22 1712 1.   概述 通过使用C/C++与Matlab混合编程,既可以享受到C代码快速执行的速度,又可以方便的使用Matlab众多的库函数和强大的绘图功能.让Matlab调用C函数是通过DLL文件实现的,而这个DLL的开发过程不仅仅可以使用Matlab自带的mex命令,还可以使用VC++开发环境,使用VC有很多好处,一是让我回到了原来熟悉的开发环境中,二能够使用更加标准的C++编译器,第三点也是最爽的,可以使用VC强大的调试功能. 此次文档更新时使用

Fix Visual Studio 2013 Razor CSHTML Intellisense in Class Library or Console Application

https://mhusseini.wordpress.com/2015/02/05/fix-visual-studio-2013-razor-cshtml-intellisense-in-class-library-or-console-application/ I tried to use a .cshtml file and the razor syntax in a console application. I was able to build the project, but the

Python/C++ in Visual Studio: An Alternative to Matlab/MEX

来自Andrew Delong的博客 http://andrewdelong.wordpress.com/2012/11/03/pythonc-in-visual-studio-an-alternative-to-matlabmex/ I spent much of my PhD working in Matlab with C++ MEX extensions. Debugging MEX extensions is frustrating: either you resort to prin

可用的Visual Studio 2013和Matlab破解地址

请看链接,证实可用. vs2013: http://tieba.baidu.com/p/3435241981 Matlab: http://jingyan.baidu.com/article/afd8f4de78c9b134e286e9b5.html 转载请标明出处,仅供学习交流,勿用于商业目的 Copyright @ http://blog.csdn.net/tandesir

C++ compile Microsoft Visual C++ Static and Dynamic Libraries

出处:http://www.codeproject.com/Articles/85391/Microsoft-Visual-C-Static-and-Dynamic-Libraries

Compile OpenSSL with Visual Studio 2019

1. Download OpenSSL source code from https://github.com/openssl/openssl/releases. 2. Download and install ActivePerl from https://www.activestate.com/products/perl/downloads/ 3. Start the visual studio 2019 developer command tool "x64 Native Tools Co