2

The point of this effort is to prevent me from dual booting windows ,having to install CPLEX twice in the same system (storage is quite limited) and ofc be able to compile the required cross-platform executables from my main os which is debian linux.

For this reason i'm using mingw64 and my compilation script looks like this:

#!/bin/sh
#COMPILATION FLAGS
FLAGS='-DIL_STD -DILOUSEMT -D_REENTRANT'
EXTRA='-std=c++11 -static -static-libgcc -static-libstdc++'
#INCLUDES
OPL_INCL='-I/opt/ibm/ILOG/CPLEX_Studio128/opl/include'
CPL_INCL='-I/opt/ibm/ILOG/CPLEX_Studio128/cplex/include'
CON_INCL='-I/opt/ibm/ILOG/CPLEX_Studio128/concert/include'
#LINKER
OPL_LIB='-L/opt/ibm/ILOG/CPLEX_Studio128/opl/lib/x64_windows_vs2017/stat_mda'
CPL_LIB='-L/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x64_windows_vs2017/stat_mda'
CON_LIB='-L/opt/ibm/ILOG/CPLEX_Studio128/concert/lib/x64_windows_vs2017/stat_mda'

#echo $FLAGS
/usr/bin/x86_64-w64-mingw32-g++ $FLAGS $OPL_INCL $EXTRA main.cpp $OPL_LIB $CON_LIB $CPL_LIB -lcplex -lm -lpthread
#g++ -std=c++11 $FLAGS $OPL_INCL main.cpp $OPL_LIB $CON_LIB $CPL_LIB -lcplex -lm -lpthread

What I have done is that I copied the windows version of the library files from another windows installation, and I'm now trying to compile my code using the global (I suppose) include files but using the windows version (.lib) of the necessary cplex libraries.

I thought that the nightmare would be the linking, but to my surprise, I didn't even manage to get there. The Mingw compiler is aborting compilation because of a generic.h file missing (which from what I understand with a bit of searching, it should be related with the kernel or something)

In file included from /opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilconcert/iloenv.h:21:0,
                 from /opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilconcert/iloalg.h:21,
                 from /opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilconcert/ilomodel.h:21,
                 from /opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilcplex/ilocplex.h:27,
                 from /opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilopl/iloopl.h:23,
                 from main.cpp:3:
/opt/ibm/ILOG/CPLEX_Studio128/opl/include/ilconcert/ilosys.h:262:21: fatal error: generic.h: No such file or directory
 #include "generic.h"
                     ^
compilation terminated.

I also tried just for testing to compile using g++ and this error was quickly bypassed and as expected the new errors are related with linking the cplex library : /usr/bin/ld: cannot find -lcplex, which is probably missing cause I have not included the linux library folders.

Do I have any hopes to do that or is this impossible in the first place?

PS: I have a much simpler piece of code where I'm doing exactly the same thing (no CPLEX) involved and compilation works like a charm. So I suppose that the issue should be also CPLEX related.

Greg K.
  • 686
  • 1
  • 5
  • 18

1 Answers1

1

The short answer is no; you probably don't have any hope of getting this to work.

In ilosys.h at line 262, we see the following:

#if !(defined(name2))
# if defined(ILO_MSVC) || defined(ILO_LINUX) || defined(ILO_APPLE) || defined(ILO_HP11)
#  undef name2
#  define name2(a,b)      _name2_aux(a,b)
#  define _name2_aux(a,b)      a##b
# else
#include "generic.h"
# endif
#endif

The suspicious part is that ILO_MSVC is not defined and this is why generic.h is being included. If we go to ilosys.h at line 11, we see:

#if defined(_MSC_VER)
# undef  _Windows
# define _Windows
# undef  _WINDOWS
# define _WINDOWS
# undef  ILO_WINDOWS
# define ILO_WINDOWS
# undef  ILO_MSVC
# define ILO_MSVC
#include <stddef.h>
# if defined(_WIN64)
#  undef  ILO64
#  define ILO64
#  undef  ILO_WIN64
#  define ILO_WIN64
# else
#  undef  ILO_WIN32
#  define ILO_WIN32
# endif
//# if defined(ILO_MSVC8)
//#  undef _WIN32_WINNT
//#  define _WIN32_WINNT 0x0400
//# endif
#endif

So, ILO_MSVC is only defined if _MSC_VER is defined. And, _MSC_VER is only defined if you have a Microsoft Visual C++ compiler installed (e.g., see here).

Finally, if you look at the detailed system requirements for CPLEX and Windows, it's pretty clear that Microsoft Visual Studio 2015 or 2017 is required.

rkersh
  • 4,447
  • 2
  • 22
  • 31
  • 1
    hmm so this is probably why the platform versions are sufficed with vs2017 and vs2015. Thank you very much. I guess I'll use my home pc for the rescue :D – Greg K. May 23 '18 at 17:20
  • Oh btw @rkersh, since you're part of the cplex optimizer team, I suppose that you can confirm if include files are not different between different cplex distributions? I'm asking because I'm thinking maybe I can at least install the windows version over the linux one and just save a bit of space. Is this going to cause any conflicts of any sort? – Greg K. May 23 '18 at 17:26
  • As far as I know, the include files are the same regardless of the platform. However, the build process is quite complex and it wouldn’t surprise me if there is an exception to this rule. Disk space is quite cheap these days, so I don’t know that I would waste any effort on this.... – rkersh May 23 '18 at 17:33