Thread Subject: Linking C++ and Matlab using VS2003

Subject: Linking C++ and Matlab using VS2003

From: Daniel Vogel

Date: 3 Jun, 2008 21:59:02

Message: 1 of 3

I'm trying to run the engdemo.c program.
I'm using MATLAB 2008a and Microsoft C++ Visual Studio 2003 on a
Windows XP machine.

At first I was getting the following error:
error C2065: 'Engine' : undeclared identifier

So i added the following line to my cpp file:
#include "C:/Program Files/MATLAB/R2008a/extern/include/engine.h"

But then I would start getting a couple of the following errors:
error LNK2019: unresolved external symbol _engClose referenced in function
_main

So I added the following to my code:
#pragma comment (lib,"C:/Program Files/MATLAB/R2008a/extern/lib/win32/
microsoft/libeng.lib")
#pragma comment (lib,"C:/Program Files/MATLAB/R2008a/extern/lib/win32/
microsoft/libmx.lib")
#pragma comment (lib,"C:/Program Files/MATLAB/R2008a/extern/lib/win32/
microsoft/libut.lib")

This made the program link and compile. However, upon running the
program, it would close with the following error:
Unable to Locate Component
This application has failed to start because libeng.dll was not found. Re-
installing the application may fix the problem.

So I copied libeng.dll from C:/Program Files/MATLAB/R2008a/bin/win32 to
my project directory. It then asked me for another dll, which I also copied.
This went on a couple of times until I got tired and copied over all the dlls in
the win32 directory to my project directory. The program now opens and
immediately crashes. A window pops up with the following message:
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: c:\Documents and...
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

The output on my project window says:
Severe:
MATLAB:I18n:MissingICUData - ICU Data not found.
The program '[2760] c:\Documents and
Settings\Administrator\Desktop\simple\PumaClient.exe: Native' has exited
with code 2 (0x2).


I have read the "Compiling and Linking MATLAB? Engine Programs" section
of the help. but I'm obviously confused and would really appreciate if you
could walk me on this one...

Thank you very very much!

Subject: Linking C++ and Matlab using VS2003

From: James Tursa

Date: 4 Jun, 2008 00:03:02

Message: 2 of 3


How are you compiling your program? Are you using the mex
command from the MATLAB command line, or are you trying to
do the compile from within the Visual Studio environment?
I usually do the compile using the mex command at the
MATLAB prompt, but this usually means I have to manually
copy any dll files from the C++ or Fortran compiler
directories and then specify them in the mex command to
get the link to work. I haven't tried the other way, as
you seem to be doing.

James Tursa

Subject: Linking C++ and Matlab using VS2003

From: Daniel Vogel

Date: 4 Jun, 2008 22:14:02

Message: 3 of 3

"James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in message
<g24m3m$1cv$1@fred.mathworks.com>...
>
> How are you compiling your program? Are you using the mex
> command from the MATLAB command line, or are you trying to
> do the compile from within the Visual Studio environment?
> I usually do the compile using the mex command at the
> MATLAB prompt, but this usually means I have to manually
> copy any dll files from the C++ or Fortran compiler
> directories and then specify them in the mex command to
> get the link to work. I haven't tried the other way, as
> you seem to be doing.
>
> James Tursa
>


I'm trying to compile it directly from VS2003. I solved my problem
downgrading from the latest version of Matlab to 6.5 (which I had lying
around). It now works perfectly only with the linking of the libraries + dll
files.


Could this be a bug in Matlab R2008a?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
vs2003 Daniel Vogel 3 Jun, 2008 18:00:24
engine Daniel Vogel 3 Jun, 2008 18:00:23
matlab engine Daniel Vogel 3 Jun, 2008 18:00:23
linking Daniel Vogel 3 Jun, 2008 18:00:23
visual studio 2003 Daniel Vogel 3 Jun, 2008 18:00:23
compiling Daniel Vogel 3 Jun, 2008 18:00:23
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com