MATLAB/CPLEX MEX-Files Downloads

Mexfile Downloads

Each MATLAB utility consists of an M-file and source code for a C-language MEX-file. You will need to compile the MEX-files yourself, as the binaries may contain proprietary CPLEX code. This web page does contain instructions for compiling the MEX-files on various platforms.

To download each file, right click on it and choose "Save Link as".

lp_cplex.m
lp_cplex_mex.c
qp_cplex.m
qp_cplex_mex.c

Compiling the MEX-Files: Directions by platform

SPARC Solaris (and probably other forms of UNIX)

  1. If you have not compiled any MEX-files before, you will need to set up your environment so that MEX-Files can be compiled from the UNIX command prompt via the 'mex' command. For directions on how to do this, see MATLAB's Application Program Interface User's Guide. Make sure that this is working by using one of the MATLAB test MEX-files.

  2. Include the location of the CPLEX include files and libraries in the mex command as follows:

    mex -Iinclude_directory -Llib_directory -lcplex filename.c

    For example, on my system, I issue this command as:

    mex -I/s/cplex-6.5/include -L/s/cplex-6.5/lib -lcplex lp_cplex_mex.c

  3. Issue this command for each of the C files.

Windows 9x/2000/NT

  1. If you have not compiled any MEX-files before, you will need to set up your environment so that MEX-Files can be compiled from the DOS command prompt via the 'mex' command. For directions on how to do this, see MATLAB's Application Program Interface User's Guide. Make sure that this is working by using one of the MATLAB test MEX-files.

  2. Add the root CPLEX directory to your system path. This is typically c:\progra~1\cplex, but this may vary depending on how CPLEX is installed on your system. On Windows NT, set the path via the Control Panel by clicking on System and choosing the Environment tab. On Windows 9x, presumably you do this via the autoexec.bat file (I haven't tried this.) My experience has been that long file names don't work in this context: you need to enter the directory name as "progra~1", not as "Program Files".

  3. Download this mexopts.bat file, which I downloaded and modified from Mathworks. You may need to edit this file to reflect the appropriate locations of MATLAB, CPLEX, and Microsoft Visual Studio on your system. Make sure that this file is in the same directory with the MEX-files that you downloaded.

  4. From a DOS command prompt, go to the directory with the MEX-files and the mexopts.bat file, and issue the commands:

    mex lp_cplex_mex.c
    mex qp_cplex_mex.c



Return to main MATLAB/CPLEX MEX-Files page.