I have successfully installed CPLEX 12.8.0 on my Mac, which runs High Sierra. I used the R package cplexAPI
, which actually uses the C API behind the scene, for a linear programming problem, and it worked totally fine. Now I want to use the C++ API; I'm already using Rcpp to generate the very large constraint matrix anyway so I don't want intermediate objects in R before the entire linear programming problem is solved. I told the compiler (I use the clang4 from CRAN) where the header files and libraries of both CPLEX and Concert are (by
PKG_CXXFLAGS=-I/<path to CPLEX>/include -I/<path to concert>/include
and
PKG_LIBS=-L/<path to CPLEX>/lib/x86-64_osx/static_pic -lcplex -lcplexdistmip -lilocplex -L/<path to concert>/lib/x86-64_osx/static_pic -lconcert
in the .R/Makevars file), and the compiler successfully found them. I just compiled a cpp file in RStudio that has #include <ilcplex/ilocplex.h>
. Then I got this error:
/Applications/CPLEX_Studio128/concert/include/ilconcert/ilosys.h:391:10: fatal error: 'iostream.h' file not found
#include <iostream.h>
^~~~~~~~~~~~
1 error generated.
That's not apparently my, R, RStudio, or Rcpp's fault - it's a problem with a Concert header file. I then opened that file; it has lots of if statements, and has #include <iostream>
, which works. Somehow it just directed me to #include <ilcplex/ilocplex.h>
. It could also be the -DIL_STD
preprocessor directive. I read in a previous question that IL_STD
could be why. However, I don't know how to set that up for R, so how to do that? Is there something in .R/Makevars for that? OK, I don't know much C++. Thanks a lot.
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] viridis_0.5.0 viridisLite_0.3.0 rhdf5_2.22.0 RcppParallel_4.3.20
[5] profvis_0.3.4 microbenchmark_1.4-4 data.table_1.10.4-3 doParallel_1.0.11
[9] iterators_1.0.9 foreach_1.4.4 cplexAPI_1.3.3 Matrix_1.2-12
[13] Rcpp_0.12.15 RevoUtils_10.0.7
loaded via a namespace (and not attached):
[1] pillar_1.1.0 compiler_3.4.3 plyr_1.8.4 base64enc_0.1-3 tools_3.4.3
[6] zlibbioc_1.24.0 digest_0.6.15 jsonlite_1.5 evaluate_0.10.1 tibble_1.4.2
[11] gtable_0.2.0 lattice_0.20-35 rlang_0.1.6 yaml_2.1.16 gridExtra_2.3
[16] stringr_1.2.0 knitr_1.19 htmlwidgets_1.0 rprojroot_1.3-2 grid_3.4.3
[21] rmarkdown_1.8 ggplot2_2.2.1 magrittr_1.5 backports_1.1.2 scales_0.5.0
[26] codetools_0.2-15 htmltools_0.3.6 colorspace_1.3-2 stringi_1.1.6 lazyeval_0.2.1
[31] munsell_0.4.3