0

I've had a great deal of issues installing Rcplex in windows. Here is my makevars.win:

set CPLEX_DIR='C:/Program Files/IBM/ILOG/CPLEX_Studio1263/cplex/'
ifeq "$(WIN)" "64"
PKG_LIBS = -L"${CPLEX_DIR}/bin/x64_win64" -lcplex201 -lm
PKG_CPPFLAGS = -D_LP64 -I"${CPLEX_DIR}/include" -DBUILD_CPXSTATIC
else
PKG_LIBS = -L"${CPLEX_DIR}/bin/x86_win32" -lcplex201 -lm
PKG_CPPFLAGS = -I"${CPLEX_DIR}/include"
endif

Here is the result of attempting to install the package in R:

> install.packages("Rcplex")
Installing package into 'C:/Users/dalgleishjl/Documents/R/win-library/4.1'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
Package which is only available in source form, and may need
  compilation of C/C++/Fortran: 'Rcplex'
Do you want to attempt to install these from sources? (Yes/no/cancel)
installing the source package 'Rcplex'

trying URL 'https://cloud.r-project.org/src/contrib/Rcplex_0.3-3.tar.gz'
Content type 'application/x-gzip' length 49931 bytes (48 KB)
downloaded 48 KB

* installing *source* package 'Rcplex' ...
** package 'Rcplex' successfully unpacked and MD5 sums checked
** using staged installation
** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"gcc  -I"c:/PROGRA~1/R/R-41~1.1/include" -DNDEBUG -I""C:/Program Files/IBM/ILOG/CPLEX_Studio1263/cplex/"/include"         -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c Rcplex.c -o Rcplex.o
     41 [main] make 18852 C:\Rtools\bin\make.exe: *** fatal error in forked process - MapViewOfFileEx '(null)'(0x2B8), Win32 error 5.  Terminating.
      1 [main] make 12244 fork: child 18852 - died waiting for dll loading, errno 11
make: fork: Resource temporarily unavailable
ERROR: compilation failed for package 'Rcplex'
* removing 'C:/Users/dalgleishjl/Documents/R/win-library/4.1/Rcplex'

The downloaded source packages are in
        'C:\Users\dalgleishjl\AppData\Local\Temp\2\RtmpmQ1n1b\downloaded_packages'
Warning message:
In install.packages("Rcplex") :
  installation of package 'Rcplex' had non-zero exit status

Here is what happens when installing to a git cloned copy of Rcplex:

C:\Users\dalgleishjl\Documents\gGnome\Rcplex>R CMD INSTALL .
* installing to library 'C:/Users/dalgleishjl/Documents/R/win-library/4.1'
* installing *source* package 'Rcplex' ...
file 'src/Makevars.win' has the wrong MD5 checksum
** using staged installation
** libs

*** arch - i386
make: *** No rule to make target '/Program', needed by 'set'.  Stop.
ERROR: compilation failed for package 'Rcplex'
* removing 'C:/Users/dalgleishjl/Documents/R/win-library/4.1/Rcplex'

UPDATE: After changing makevars.Win to have the following text: CPLEX_DIR="C:/CPLEX/cplex/" ifeq "$(WIN)" "64" PKG_LIBS = -L"${CPLEX_DIR}/bin/x64_win64" -lcplex1263 -lm PKG_CPPFLAGS = -D_LP64 -I"${CPLEX_DIR}/include" else PKG_LIBS = -L"${CPLEX_DIR}/bin/x86_win32" -lcplex1263 -lm PKG_CPPFLAGS = -I"${CPLEX_DIR}/include" endif

I get the following result installing within the directory of gGnome (which also uses Rcplex):

$ /C/R/R-4.1.1/bin/x64/R.exe CMD INSTALL --no-multiarch .
* installing to library 'C:/R/R-4.1.1/library'
* installing *source* package 'gGnome' ...
** using staged installation
** libs
"C:/rtools40/mingw64/bin/"gcc  -I"C:/R/R-4.1.1/include" -DNDEBUG -D_LP64 -I""C:/CPLEX/cplex/"/include"         -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c Rcplex2.c -o Rcplex2.o
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:35:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060200)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:35:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060200)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:335:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060200)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:335:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060200)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:462:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:462:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:488:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:488:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:668:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:668:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1032:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1032:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1049:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1049:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1178:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060100)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1178:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12060100)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1218:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1218:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1224:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1224:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1390:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1390:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1395:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1395:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1430:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1430:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1460:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1460:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1676:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1676:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1924:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:1924:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:62: error: expected ')' before 'deprecated'
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                                              ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:2341:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cpxconst.h:249:41: error: expected identifier or '(' before ')' token
 #      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
                                         ^~~~~~~~~~
C:/CPLEX/cplex/include/ilcplex/cplex.h:2341:1: note: in expansion of macro 'CPXDEPRECATEDAPI'
 CPXDEPRECATEDAPI(12040000)
 ^~~~~~~~~~~~~~~~
make: *** [C:/R/R-4.1.1/etc/x64/Makeconf:238: Rcplex2.o] Error 1
ERROR: compilation failed for package 'gGnome'
* removing 'C:/R/R-4.1.1/library/gGnome'
  • I'm using CPLEX version 12.6.3, following the exact version called for in makevars.win of Rcplex. – James Dalgleish Oct 05 '21 at 17:51
  • I don't know that it's related, but I also don't know that it isn't ... spaces in path names for R on Windows [can be problematic](https://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-install-R-for-Windows_003f) (and other reasons I can't find refs for atm), so my installations are under `C:/R/R-4.0.5/` and `C:/Rtools/`. – r2evans Oct 05 '21 at 18:46
  • It may be. I've managed to get it to work in linux without using any spaces at all. Obviously there are many things that are different between these two types of installs, but perhaps that could be it. I'll try it. Thanks! I think the same idea might apply to the cplex directory as well. – James Dalgleish Oct 05 '21 at 18:49
  • Yeah, I'm repeatedly surprised by how well R works with some things and then gets confused about spaces in paths. (Look at `system` and `system2`, after all, those are brain-dead-broken with regards to spaces in arguments. Whenever I see error messages from compiling things in R on Windows, I add a comment. Sometimes it fixes the glitch. Good luck! I don't use `Rcplex` so won't be able to comment much further.) – r2evans Oct 05 '21 at 18:51
  • So, I've tried doing as you said. It now breaks in a way that seems like it's getting further, but it's still not running in windows. – James Dalgleish Oct 06 '21 at 03:39

1 Answers1

1

So, after many days of trying to get this to work, I've got it to run in windows. Here's what I did (for both Rcplex and gGnome): My makevars.win file in C:/gGnome/src/makevars.win and C:/Rcplex/src/makevars.win is below. The first line is the most critical.

CPLEX_DIR="C:/CPLEX/cplex/"
ifeq "$(WIN)" "64"
PKG_LIBS = -L"${CPLEX_DIR}/bin/x64_win64" -lcplex1263 -lm
PKG_CPPFLAGS = -D_LP64 -I"${CPLEX_DIR}/include" -DBUILD_CPXSTATIC
else
PKG_LIBS = -L"${CPLEX_DIR}/bin/x86_win32" -lcplex1263 -lm
PKG_CPPFLAGS = -I"${CPLEX_DIR}/include"
endif

I then did the following, using r2evans comment, and using mingw64.exe directly to compile (within the /C/Rcplex/ and /C/gGnome/ directories):

/C/R/R-4.1.1/bin/x64/R.exe CMD INSTALL --no-multiarch --no--test-load

I did export CPLEX_DIR="C:/CPLEX/cplex/" before running the above line, which is critical... Rcplex has to know where to find cplex.

It then will install, but in my case, the DLLs failed to load.

I followed another post on stackoverflow, which encouraged me to inspect the DLLs with Dependency Walker (and find which DLLs the Rcplex.dll was having trouble importing/finding):

LoadLibrary project.dll failed. The specified module could not be found

Finally, with the names of the DLLs that the Rcplex.dll could not find in dependency walker, I searched and found a post on MS technet, which suggested to reinstall Visual Studio redistributable:

https://social.technet.microsoft.com/Forums/en-US/8f58e95f-60c5-44ac-85b5-2531914ac738/missing-all-apimswin-dlls-many-apps-will-not-start-including-vc2017redistx64-and?forum=WinServerPreview

I reinstalled and restarted so that the registry changes would link the DLLs correctly and now both gGnome and Rcplex work. I'm not sure everyone will go this far to make this package work, but if you're determined, feel free to use what I did.

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • This is great sleuthing! While it might seem that not many people experience (or at least ask about) this specific problem, I'm confident that the detailed walk-through will be a good start if not complete solution for them. Nice! – r2evans Oct 06 '21 at 14:03