Help with installation of Gurobi Mex for Matlab

1,133 views
Skip to first unread message

Patrik

unread,
Jan 31, 2012, 10:23:14 AM1/31/12
to Gurobi Optimization
Hi,

I would like help to install Gurobi Mex for use in Matlab R2009a (v.
7.8.0.347, 64-bit) on a Win 7 (64-bit) computer. I have followed the
instructions on http://www.convexoptimization.com/wikimization/index.php/Gurobi_Mex:_A_MATLAB_interface_for_Gurobi.

The issue surfaces when I attempt to install a compiler. I downloaded
and installed Microsoft Visual C++ 2008 Express and SDK 7.1 with
default options. Once this has been completed I am stuck, as follows:

>> mex -setup
Please choose your compiler for building external interface (MEX)
files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler:
[1] Microsoft Visual C++ 2008 Express in C:\Program Files
(x86)\Microsoft Visual Studio 9.0

[0] None

Compiler: 1

Please verify your choices:

Compiler: Microsoft Visual C++ 2008 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0

Are these correct [y]/n? y

*****************************************************************************
Error: Could not find the 64-bit compiler. This may indicate that
the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-
files
Microsoft Visual C++ 2008 Express Edition requires that these
two
packages are installed properly.
*****************************************************************************

I have checked that the option X64 compiler is highlighted.

Thanks for your help

Wotao Yin

unread,
Jan 31, 2012, 5:07:57 PM1/31/12
to gur...@googlegroups.com
The error is because VC Express does not include a 64-bit compiler,
just a 32-bit one.

You can install the latest version Windows platform SDK, free of
charge, and check the options: compilers and x64 libraries. Then after
a system reboot, you will see a second option in "mex -setup" with
64-bit compiling.

Also I can send you a precompiled mex for 64-bit Windows.

Wotao

Wotao Yin

unread,
Jan 31, 2012, 10:56:03 PM1/31/12
to Gurobi Optimization
I uploaded a mexw64 file at http://bit.ly/wLKtcl. It was compiled with
Win 7 64-bit, Matlab 2011b, Gurobi 4.6.1, and Gurobi Mex 1.61.

On Jan 31, 4:07 pm, Wotao Yin <wotao....@gmail.com> wrote:
> The error is because VC Express does not include a 64-bit compiler,
> just a 32-bit one.
>
> You can install the latest version Windows platform SDK, free of
> charge, and check the options: compilers and x64 libraries. Then after
> a system reboot, you will see a second option in "mex -setup" with
> 64-bit compiling.
>
> Also I can send you a precompiled mex for 64-bit Windows.
>
> Wotao
>
>
>
>
>
>
>
> On Tue, Jan 31, 2012 at 9:23 AM, Patrik <patrik.r.jo...@gmail.com> wrote:
> > Hi,
>
> > I would like help to install Gurobi Mex for use in Matlab R2009a (v.
> > 7.8.0.347, 64-bit) on a Win 7 (64-bit) computer. I have followed the
> > instructions onhttp://www.convexoptimization.com/wikimization/index.php/Gurobi_Mex:_....

Patrik

unread,
Feb 1, 2012, 4:43:27 AM2/1/12
to Gurobi Optimization
Hi Wotao,

When I installed Windows SDK 7.1 (http://www.microsoft.com/download/en/
details.aspx?id=8279) I selected all options including the one called
"Visual C++ Compilers" with the following description: "Visual C++
Compilers Installs the Visual Studio 2010 Visual C++ Compilers.
Includes x86, x64, and Itanium compilers for C Runtime (CRT)." and the
unit has been rebooted, but still I obtain the same response to mex -
setup. I would appreciate very much if you could please send me the
precompiled mex for 64-bit Windows as you suggested, any other
suggestions are also welcomed.

Thanks for your help, Patrik

On Feb 1, 12:07 am, Wotao Yin <wotao....@gmail.com> wrote:
> The error is because VC Express does not include a 64-bit compiler,
> just a 32-bit one.
>
> You can install the latest version Windows platform SDK, free of
> charge, and check the options: compilers and x64 libraries. Then after
> a system reboot, you will see a second option in "mex -setup" with
> 64-bit compiling.
>
> Also I can send you a precompiled mex for 64-bit Windows.
>
> Wotao
>
>
>
>
>
>
>
> On Tue, Jan 31, 2012 at 9:23 AM, Patrik <patrik.r.jo...@gmail.com> wrote:
> > Hi,
>
> > I would like help to install Gurobi Mex for use in Matlab R2009a (v.
> > 7.8.0.347, 64-bit) on a Win 7 (64-bit) computer. I have followed the
> > instructions onhttp://www.convexoptimization.com/wikimization/index.php/Gurobi_Mex:_....

Wotao Yin

unread,
Feb 1, 2012, 12:00:40 PM2/1/12
to gur...@googlegroups.com
Patrik,

That's strange. In Matlab R2010b, "mex -setup" gives two options.

[1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files
(x86)\Microsoft Visual Studio 10.0
[2] Microsoft Visual C++ 2010 Express in C:\Program Files
(x86)\Microsoft Visual Studio 10.0

and option [1] works fine for 64-bit compiling.

Perhaps R2009a does not support the latest SDKs.

I uploaded a mexw64 file at http://bit.ly/wLKtcl.

Wotao

Patrik

unread,
Feb 2, 2012, 5:35:46 AM2/2/12
to Gurobi Optimization
Dear Wotao,

Thanks for your support. I downloaded the mexw64 file and saved it in
the same folder where gurobi_mex.c was kept (i.e. the folder
downloaded from SourceForge for gurobi_mex_v1.61. I then started
Matlab and added this folder (gurobi_mex_v1.61) to the path and
thereafter following the instructions on the convexoptimization site
tried the command 'compile_mex', with the following results:

----------------------
>> mex -setup
Please choose your compiler for building external interface (MEX)
files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler:
[1] Microsoft Visual C++ 2008 Express in C:\Program Files
(x86)\Microsoft Visual Studio 9.0

[0] None

Compiler: 1

Please verify your choices:

Compiler: Microsoft Visual C++ 2008 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0

Are these correct [y]/n? y

*****************************************************************************
  Error: Could not find the 64-bit compiler.  This may indicate that
the
         "X64 Compilers and Tools" or the Microsoft Windows Software
         Development Kit (SDK) is not installed.  To build 64-bit MEX-
files
         Microsoft Visual C++ 2008 Express Edition requires that these
two
         packages are installed properly.
*****************************************************************************

Trying to update options file: C:\Users\patjon\AppData\Roaming
\MathWorks\MATLAB\R2009a\mexopts.bat
From template:              C:\PROGRA~1\MATLAB\R2009a\bin\win64\mexopts
\msvc90freeopts.bat

Done . . .

**************************************************************************
  Warning: The MATLAB C and Fortran API has changed to support MATLAB
           variables with more than 2^32-1 elements.  In the near
future
           you will be required to update your code to utilize the
new
           API. You can find more information about this at:
           http://www.mathworks.com/support/solutions/data/
1-5C27B9.html?solution=1-5C27B9
           Building with the -largeArrayDims option enables the new
API.
**************************************************************************

>> compile_mex
Have you run "mex -setep" to set up a C compiler for Matlab? Y/N [Y]:
y

To build gurobi_mex.mexw64, we are calling:
mex -O -largeArrayDims -I"C:\gurobi461\win64\include" "C:\Users\patjon
\Dropbox\PROJECTS\Computational modeling
\gurobi_mex_v1.61\gurobi_mex.c" "C:\gurobi461\win64\lib\gurobi46.lib"
"C:\Users\patjon\Dropbox\PROJECTS\Computational modeling
\gurobi_mex_v1.61\libut\libut_win64.lib"
  Error: Could not find the compiler "cl" on the DOS path.
         Use mex -setup to configure your environment properly.

  C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Unable to locate
compiler.

??? Error using ==> mex at 218
Unable to complete successfully.

Error in ==> compile_mex at 90
eval(cmpl_cmd);
----------------

Before that, I also tried without first running mex -setup, identical
results.

I also thereafter tried with or without setting the path to c:
\gurobi461 (where gurobi itself is located) and to also run the
following command: 'gurobi_mex' with the following results with or
without gurobi461 on the path:

----------------
>> gurobi_mex
Gurobi Mex Version 1.61. Gurobi Library Version 4.6.1.
Check input & ouput.
??? Error using ==> gurobi_mex
8 or 9 input required.
--------------------

Any suggestions would be appreciated, I am a wet-lab biologist so it
is not straightforward to sort it out. If the version of Matlab is the
problem, I will need more time to fix it as our service contract has
run out so we don't receive updates any longer.

Thanks for your help, Patrik

On Feb 1, 7:00 pm, Wotao Yin <wotao....@gmail.com> wrote:
> Patrik,
>
> That's strange. In Matlab R2010b, "mex -setup" gives two options.
>
> [1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files
> (x86)\Microsoft Visual Studio 10.0
> [2] Microsoft Visual C++ 2010 Express in C:\Program Files
> (x86)\Microsoft Visual Studio 10.0
>
> and option [1] works fine for 64-bit compiling.
>
> Perhaps R2009a does not support the latest SDKs.
>
> I uploaded a mexw64 file athttp://bit.ly/wLKtcl.

Wotao Yin

unread,
Feb 3, 2012, 5:03:26 PM2/3/12
to gur...@googlegroups.com
Dear Patrik,

I am inclined to believe that your Matlab does not support latest MSVC Express or platform SDK.

Best,
Wotao

Patrik

unread,
Feb 4, 2012, 9:31:51 AM2/4/12
to Gurobi Optimization
Thanks Wotao, I will obtain the updated Matlab and then try again, and
let you know how it went. It will take time though, delayed by
administration etc..

Regards, Patrik
> > *************************************************************************** **
> >   Error: Could not find the 64-bit compiler.  This may indicate that
> > the
> >          "X64 Compilers and Tools" or the Microsoft Windows Software
> >          Development Kit (SDK) is not installed.  To build 64-bit MEX-
> > files
> >          Microsoft Visual C++ 2008 Express Edition requires that these
> > two
> >          packages are installed properly.
>
> > *************************************************************************** **
>

robi...@stolaf.edu

unread,
Jan 14, 2014, 4:27:37 PM1/14/14
to gur...@googlegroups.com
Hi Wotao,
I'm a beginner, so forgive me if the question is trivial, but I have successfully followed instructions for installing Gurobi Mex in MATLAB through step 3, but when I run compile_mex
I get the following error:


Error using  +
Matrix dimensions must agree.

Error in compile_mex (line 40)
    grb_ver = gurobi_addr([6 7]+pos);

I am using Windows, with a 32-bit Matlab. I am wondering if the error message has something to do with the following message: "The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements.  In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html  Building with the -largeArrayDims option enables the new API."

I really appreciate the help!
Thank you

LS

unread,
Apr 13, 2015, 5:03:46 PM4/13/15
to gur...@googlegroups.com
Hi Everyone!
I am having trouble getting gurobi_mex to work with older versions of gurobi specifically v5.0.2.  Because you cannot directly install a license for this version you have to first install v6.03 and then download the license for this version and then install a lower version of gurobi (again in my case v5.0.2)  However when I try and run gurobi_mex with the v5.0.2 I get the following error:
Error using gurobi_mex
Error: could not create environment. Please make sure that GUROBI has a license and been validated.

Does anyone have any ideas on how to fix this. 

Thanks for any help!

Manasa Surakala

unread,
Aug 11, 2015, 8:42:49 AM8/11/15
to Gurobi Optimization
Hi, 
   I'm getting the same error as Serina Lee Robinson. I've installed Gurobi v6.0.4 and trying to install gurobi mex v1.61. 
@Serina, if your error is resolved please let me know how to go about it.

Thanks a lot in advance,
Manasa.

Narendran Sekar

unread,
Jul 27, 2016, 9:40:02 PM7/27/16
to Gurobi Optimization
Hello,
I am getting the following error..

Invalid MEX-file 'C:\Program Files\MATLAB\R2016a\toolbox\gurobi652\win64\matlab\gurobi.mexw64': The specified
module could not be found.

Error in solveCobraLP (line 973)
        resultgurobi = gurobi(LPproblem,param);

Error in optimizeCbModel (line 213)
    solution = solveCobraLP(LPproblem);

The gurobi folder already contains the gurobi.mexw64, but I don't know what went wrong?

Can anybody help me out? Thanks in Advance,
Narendran


Reply all
Reply to author
Forward
0 new messages