Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linking C++ and Matlab using VS2003

192 views
Skip to first unread message

Daniel Vogel

unread,
Jun 3, 2008, 5:59:02 PM6/3/08
to
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!

James Tursa

unread,
Jun 3, 2008, 8:03:02 PM6/3/08
to

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

Daniel Vogel

unread,
Jun 4, 2008, 6:14:02 PM6/4/08
to
"James Tursa" <aclassyguy...@hotmail.com> wrote in message
<g24m3m$1cv$1...@fred.mathworks.com>...


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?

Gary Willenbring

unread,
Mar 15, 2010, 5:02:06 PM3/15/10
to
"Daniel Vogel" <vo...@stanford.edu> wrote in message <g2743a$ajq$1...@fred.mathworks.com>...

---------------------------------------------------
Hi - has a workaround for this issue been identified? I'm seeing the same thing with example engwindemo on 2009A. Thanks. Gary


Thanks, Gary

Mike

unread,
Apr 5, 2010, 9:08:04 PM4/5/10
to

> ---------------------------------------------------
> Hi - has a workaround for this issue been identified? I'm seeing the same thing with example engwindemo on 2009A. Thanks. Gary
>
>
> Thanks, Gary


I was able to compile the sample projects on a computer with the full Matlab environment + the compiler installed. Now I'm trying to run the resulting executable on a computer with only the matlab compiler runtime installed (because we want to distribute this program to people who don't have matlab). And I'm getting the same error. Have not yet found a solution.

Dominique

unread,
Apr 8, 2010, 9:00:22 AM4/8/10
to
I am having the same problem and i really start thinking that there are something seriously wrong with matlab !!!

"Mike " <schn...@ict.usc.edu> wrote in message <hpe1hk$1sp$1...@fred.mathworks.com>...

Mike

unread,
Apr 9, 2010, 6:24:04 PM4/9/10
to
OK I was able to get it working. I had to update the PATH to include the location of the (which I had already done) to this: C:\Program Files\MATLAB\MATLAB Compiler Runtime\v711\bin\win32

That allows the .exe to find the .dll files required by the matlab compiler runtime.

Then I had to reboot (I think this was the missing step).

Also the .exe has to be compiled against the same version of the .dll that it is being run with.

"Dominique " <domd...@gmail.com> wrote in message <hpkk16$pnk$1...@fred.mathworks.com>...

Aditya

unread,
Apr 13, 2010, 3:09:05 AM4/13/10
to
"Mike " <schn...@ict.usc.edu> wrote in message <hpo9e4$b30$1...@fred.mathworks.com>...

> OK I was able to get it working. I had to update the PATH to include the location of the (which I had already done) to this: C:\Program Files\MATLAB\MATLAB Compiler Runtime\v711\bin\win32
>
> That allows the .exe to find the .dll files required by the matlab compiler runtime.
>
> Then I had to reboot (I think this was the missing step).
>
> Also the .exe has to be compiled against the same version of the .dll that it is being run with.
>
> "Dominique " <domd...@gmail.com> wrote in message <hpkk16$pnk$1...@fred.mathworks.com>...
> > I am having the same problem and i really start thinking that there are something seriously wrong with matlab !!!
> >
> > "Mike " <schn...@ict.usc.edu> wrote in message <hpe1hk$1sp$1...@fred.mathworks.com>...
> > >

Hi

Even i am trying to make this demo work. I was able to run the demo in Visual studio 2005 version. But when i do the same steps . The build is complete it says that i am missing a libeng.dll
So "Matlab engine can't open"
I have tried the path to vs->tools->options->projects&solutions->C++ directories. As i know where the libeng.dll is there in the matlab folder. Also i tried attaching it in the solution explorer. As a existing item. Please help

thanks in advance

Vidi

unread,
Jan 19, 2011, 5:01:06 AM1/19/11
to
Hi there,

I run engdemo.cpp from matlab R2009b on VS2005, and I got this error:
"engwindemo.exe - system error. The program can't start because libmx.dll is missing from your computer...."

I can find libmx.dll in the matlab root: C:/Program Files/MATLAB/R2009b/extern/lib/win32/microsoft
I also have created the path to Matlab in the VS2005 "Include files" and "Library files" Directories, and included the appropriate library files in VS2005. Wonder why do I get this message.

Really appreciate for your help.

Thank you,
Vidy

Victor

unread,
Mar 21, 2011, 10:47:04 PM3/21/11
to
I have the same error!!
I really don't know what to do!
I'm Linking C++ with matlab using VS2008 and matlab 2010a
When i copy the missing .dll's (icudt40.dll and others) to the Visual Studio project
at the run of the aplication i get the exactly same message:
severe:
Matlab.. missing ICUData........

HELP PLEASE!

Seth

unread,
Jun 17, 2011, 3:05:20 PM6/17/11
to
I fixed the missing libmx.dll error for the engwindemo.cpp example program by adding the directory containing libmx.dll (in my case C:\Program Files (x86)\MATLAB\R2009bSP1\bin\win32) to the PATH variable in my system Environment Variables.

Right click My Computer -> Properties -> Advanced Tab -> Environment Variables -> Edit PATH Variable. Add the directory containing libmx.dll to the end.

Then close and reopen your visual studio solution, and the program should run.

"Victor" wrote in message <im92j8$les$1...@fred.mathworks.com>...

Timothy

unread,
Aug 5, 2011, 3:39:26 PM8/5/11
to
Seth is correct, once you have compiled your program/demo, the executable looks in the directories listed in the PATH environment variable to locate the necessary DLL's.

"Seth " <wingm...@hotmail.com> wrote in message <itg8hg$ep5$1...@newscl01ah.mathworks.com>...

riccardo....@gmail.com

unread,
Apr 29, 2014, 5:12:16 AM4/29/14
to
We had the same problem with Matlab R2009b and the solution was ...

copying the file icudt40l.dat from the same Matlab folder containing the dll to your working directory.

Hope it works for you
0 new messages