1

I want to install the cplexAPI R package to interact with the newest version of IBM CPLEX solver (IBM ILOG CPLEX Optimizers 12.10.0) but I keep getting the following error:

CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"gcc  -I"C:/Users/USERNAME/R/R-40~1.3/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include"         -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c cplexAPI.c -o cplexAPI.o
C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include/ilcplex/cpxconst.h:251:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include/ilcplex/cplex.h:1214:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12090000)
 ^~~~~~~~~~~~~~~~
C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include/ilcplex/cpxconst.h:251:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include/ilcplex/cplex.h:1214:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12090000)
 ^~~~~~~~~~~~~~~~
C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\include/ilcplex/cpxconst.h:251:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
           
     

I have done the following:

  1. Installed Rtools40 from [https://cran.r-project.org/bin/windows/Rtools/][1], and added PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" in my .Renviron file

  2. Installed IBM CPLEX in C:\Program Files\IBM\ILOG\CPLEX_Studio1210

  3. Added the following paths in my .Renviron file:

    CPLEX_STUDIO_DIR = "C:\Program Files\IBM\ILOG\CPLEX_Studio1210"

    CPLEX_STUDIO_LIB = "C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\lib"

  4. Run install.packages('cplexAPI'). I have also tried to manually download the tar.gz file and modify the path in the Makevars.win file, but I get the same error. FYI, I have the following R version:

platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          4                           
minor          0.3                         
year           2020                        
month          10                          
day            10                          
svn rev        79318                       
language       R                           
version.string R version 4.0.3 (2020-10-10)
nickname       Bunny-Wunnies Freak Out
Adrien
  • 461
  • 5
  • 19

1 Answers1

1

This seems to be a bug in the cplex library. See also: https://stackoverflow.com/a/61199818/318752

A workaround is to add -DBUILD_CPXSTATIC to the PKG_CPPFLAGS inside the package src/Makevars.win as shown here: https://github.com/r-windows/Rcplex/commit/545254ab7cf28e97e62063c16af711ff2b46476d.

I also had to update the dll name because the cplex dll is called cplex12100.dll while the R package was still assuming cplex1263.dll. With these fixes I am able to install the package on Windows:

install.packages("slam")
install.packages('https://github.com/r-windows/Rcplex/archive/master.tar.gz', repos = NULL, INSTALL_opts = '--no-multiarch')
Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207