Graviton
Graviton

Reputation: 83254

Compiling Matlab to C++ Problem: fatal error C1083: Cannot open include file: 'windows.h'

I got this weird error when I was trying to compile matlab to C++ using the following command:

'mcc -W lib:cshared -d ' clibdir ' -T link:lib ' mfile

The error I got was:

fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

Now, I was using lcc as my compiler ( instead of the Visual Studio one), and I made sure that Windows.h was inside the lcc\include directory (C:\Program Files\MATLAB\R2006a\sys\lcc\include), and yet, I still got the missing windows.h error even though I do have it inside the include folder.

Anyone has any idea why this is so?

Note: I have read similar questions at SO, and found that those problems are related to include folders not set etc. But I do have the include path set, I believe

Upvotes: 0

Views: 4557

Answers (2)

Alexander Kosenkov
Alexander Kosenkov

Reputation: 1595

I found a workaround - in Start Menu you'll find something like Microsoft Visual Studio 2010 Express\Visual Studio Command Prompt (2010)

This will start command-prompt with all the environment variables set, including LIB, INCLUDE and so on. Then, start MATLAB from this command prompt! E.g.: simply type C:\Program Files\MATLAB\R2012a\bin\matlab.exe. In result, you can call MEX from this MATLAB session.

Upvotes: 1

Rob Kennedy
Rob Kennedy

Reputation: 163287

The error message you quote comes from Visual C++, so you're clearly not using lcc, and thus it won't make any difference what files you put in lcc's directories. Try running mbuild -setup to configure Matlab to use a different compiler command.

If you (or Matlab, on your behalf) are going to run the Visual C++ command-line compiler, then you should run it in a command prompt with all the right environment variables set up, such as the include path. Visual Studio should have put an item on your Start menu for that, or else you can run the vsvars32.bat file from within some other console window.

Upvotes: 4

Related Questions