4

I have installed MatConvNet from VLFeat and I am trying to compile it. But as I am trying to run vl_compilenn it shows the following error:

vl_compilenn
Warning: CL.EXE not found in PATH. Trying to guess out of mex setup. 
> In vl_compilenn>check_clpath (line 580)
  In vl_compilenn (line 413) 
'cl.exe' is not recognized as an internal or external command, 
operable program or batch file. 
Error using vl_compilenn>check_clpath (line 591)
Unable to find cl.exe

Error in vl_compilenn (line 413)
    check_clpath(); % check whether cl.exe in path
Karel Lenc
  • 820
  • 6
  • 11
user7029552
  • 61
  • 1
  • 1
  • 5

7 Answers7

4

install visual studio community edition ( it's the free edition ) (minwg compiler will not work) go to C:\Program Files (x86)\Microsoft Visual Studio search for cl.exe take the one appropriate for your computer architecture and copy it to the folder containing the matconvnet installation run mex -setup c++ and set it to visual studio and you're good to go

2

I have added the directory with cl.exe to my system PATH variable (you need to restart Matlab after that operation) and the compilation succeeded. The check_clpath() function was unable to find proper location of cl.exe, because it was trying to find executable in directory which does not exsist:

cl_path =

'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\bin\amd64'

after adding the cl.exe dir to PATH variable, in my case:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64

the compilation succeeded.

2

Matlab accepts Professional Version of Visual Studio Compiler as I found out in one of the posts on MatLab forums.

The following is an easier solution,

addpath(fullfile('C:', 'Program Files (x86)', 'Microsoft Visual Studio', '2017', 'Professional', 'VC', 'Tools', 'MSVC', '14.16.27023', 'bin', 'Hostx64', 'x64'));

Matlab Post for reference: https://se.mathworks.com/matlabcentral/answers/271382-mex-won-t-recognize-microsoft-visual-c-compilers

jagms
  • 21
  • 3
2

This worked for me

  1. install community visual studio 2019 professional from https://visualstudio.microsoft.com/es/downloads/
  2. move to the directory where the installer placed visual studio. In my case C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
  3. locate the cl.exe appropriate to your host and target architecture (there are four combinations x86/x64). In my case x64/x64 resulted in C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64 place the path in the environmental variable in your system
  4. within matlab, move to CF2-master\external\matconvnet\matlab and execute vl_compilenn
Joaquin
  • 21
  • 3
1

Unfortunately MatConvNet does not support MinGW compiler in the current version. On Windows, you need to install Microsoft Visual Studio. Nowdays you can download the community edition for free, e.g. here.

One of the reasons why MatConvNet does not support MinGW is that on windows it uses the GDI+ library to speed up reading image files. You can try to compile it using: vl_compilenn('EnableImreadJpeg', false)

Karel Lenc
  • 820
  • 6
  • 11
0

cl.exe is a C++ compiler.

This message means that the program cannot find this file on your computer (either because it is actually not there, or because you did not indicate its location.)

If you actually have a C++ compiler and work with Windows, go to the properties of your PC -> advanced settings -> Environment Variables (Sorry if the names are not accurate, my computer is in French but should be something similar...). Here you will have a field called PATH with most probably some paths already set. Modify it by adding the path of you C++ compiler (the folder containing cl.exe) and reboot your computer (your change is not taken into account otherwise).

I do not know how to do for other OS...

Otherwise, you need to download a C++ compiler. Visual Studio is free and has one.

Eskapp
  • 3,419
  • 2
  • 22
  • 39
  • I have already tried this.I have TDM Gcc-4.9 MinGw64bit and I have added the path to the environment variables.But the error is still coming. I have changed the line 415-418 to the following code – user7029552 Oct 25 '16 at 05:45
  • 1
    ase {'win64'} flags.nvccpass{end+1} = '-Xcompiler /MD' ; % cl_path = fileparts(check_clpath()); % check whether cl.exe in path flags.nvccpass{end+1} = '-ccbin"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64"' ; end – user7029552 Oct 25 '16 at 05:45
  • 1
    You actually don't need to completely reboot, you can just restart matlab – Alex Lamson Mar 03 '18 at 00:17
0

I also have same problem, which is because I changed the installation position of the MS VS.

I just add the path of it in vl_compilenn.m (after line 646)

% cl_path = fullfile(cc.Location, 'VC', 'bin', 'amd64');

cl_path = 'E:\WorkingSoftware\VS2017Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64';
Hong Cheng
  • 318
  • 1
  • 4
  • 19