2

The following code:

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

Gives:

Can't start MATLAB engine

I don't know what is the reason ... I have two versions of Matlab R2011a 64-bit, and R2010b 32-bit. I use engine lib of second version of matlab. OS windows 7 x64. According to some topics this problem can be caused by multiple matlab versions MATLAB Engine Windows 7 problem but i have deleted x64 Matlab from PATH enviroment variable...

Community
  • 1
  • 1
Alex Hoppus
  • 3,821
  • 4
  • 28
  • 47

1 Answers1

5

A few things to try:

  • Make sure your PATH is set to have the full path of the Matlab binary directory. For example, 64bit matlab this is C:\Program Files\MATLAB\R2011a\bin\win64. I'm not sure why you have two copies of 2011a, but I would confirm that only one install of matlab is on the current path.
  • Make sure you are using a 32bit compiler when using 32bit matlab, and 64bit compiler when using 64bit matlab. This is very important.
  • Confirm you are using a compiler that is supported
  • Try re-registering the Matlab COM. I've had to do this for a 2010/2011 install.
    • On linux, make sure csh is installed.
Chris
  • 1,532
  • 10
  • 19
  • 1
    "Especially try re-registering the MATLAB COM." – user1071136 Mar 08 '12 at 19:44
  • 1
    Because my comment is top in google search: on linux make sure csh is installed. – Chris Apr 03 '14 at 19:28
  • @Chris thanks for all these options... I've checked all of them but one. Could you explain me how to run the !matlab -regserver command properly... I've tried and couldn't... I'm running MATLAB 2013a on a RHEL cluster. – Alexis R Devitre Mar 02 '16 at 05:41
  • @AlexisRDevitre The COM regserver command is windows specific. You won't need to do this on linux. If you're having troubles getting the engine to work on linux, the #1 culprit I routinely run into is not having csh installed. I would double check that your machines have csh installed. – Chris Mar 03 '16 at 18:02
  • @Chris I did, still not working :(... I've tried to run a different code and it actually opens matlab but crashes when starting graphics to display plots... could it be that I need to ssh the server with some kind of graphical option otherwise it crashes in that step and outputs "can't start server" (the output is actually programmed into the code, like i could remove it...)... – Alexis R Devitre Mar 06 '16 at 21:40
  • @AlexisRDevitre IIRC you need X11 for the plots. If other code works, it sounds like the environment is working. I would go back to a small test case, then start adding in bits. – Chris Mar 07 '16 at 23:01
  • @Chris I am just half familiar with the X11 protocol. Is it something that should be installed on that server, is it installed by default, and how to call it? – Alexis R Devitre Mar 08 '16 at 03:42
  • @AlexisRDevitre X11: http://toastytech.com/guis/remotex11.html It would depend on the server. If it is, for example, a cluster, it likely isn't installed. You should contact your admin to see. If it is, ssh -Y will do X11 forwarding via SSH, and then when you run your code, it will open a local window with your plot. – Chris Mar 09 '16 at 15:43