1

I'm trying to run the basic Matlab enginedemo.cpp in VS2010 on Windows 7 and no matter what I do the code:

`if (!(ep = engOpen(""))) {
     fprintf(stderr, "\nCan't start MATLAB engine\n");
     return EXIT_FAILURE;
 }`

Always errors.

I had both MatlabR2012b and MatlabR2012a installed on my computer but I uninstalled MatlabR2012a and then removed all references to it from my path variable.

I am running x64 MatlabR2012b and I set my VisualC++ Win 32 Console Application.

I also already set the Debugging Environment to: {MatlabRoot}\R2012b\extern\lib\win64\microsoft

C/C++->Additional Include Directories: {MatlabRoot}\R2012b\extern\include

Linker->General->Additional Library Directories: {MatlabRoot}\R2012b\extern\lib\win64\microsoft

Linker->Input->Additional Dependencies: libmx.lib;libmat.lib;libeng.lib

My Matlab version is also registered so that shouldn't be causing the error.

I searched through some of the other stackoverflow questions concerning this and most of them seemed to fix their problems by removing older versions of matlab from the path variable but it hasn't worked for me.

Amro
  • 123,847
  • 25
  • 243
  • 454
Neppinger
  • 148
  • 1
  • 2
  • 16

1 Answers1

0

You cannot load 64 bit DLL in 32 bit application. You must make 64 bit console application if you want to work with 64 bit matlab.

You should have {MatlabRoot}\bin\win64 in your PATH (there are libeng.dll and other matlab engine libraries) so your application can find matlab engine libraries during runtime.

execute "matlab /regserver" from command prompt. (to re-register COM components from Matlab 2012a - might not be required, but to be sure)

Hope this helps.

durasm
  • 174
  • 3
  • 10
  • I changed the project to x64 under configuration management still not working and I already have {MatlabRoot}\R2012b\etc\win64........{MatlabRoot}\R2012b\bin\win64 and {MatlabRoot}\R2012b\bin on my path variable another person I know has the exact same settings and it works for him, the only difference being he only ever had Matlab R2012b installed – Neppinger Feb 14 '13 at 14:56
  • If anyone was having problems like me running the engine run Matlab as administrator then type !matlab/regserver fixed the issue.... I would always get an error from the cmd – Neppinger Feb 14 '13 at 18:12