Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

trying to use Cplex with gcc

  • 1.  trying to use Cplex with gcc

    Posted Wed January 06, 2016 12:15 PM

    Originally posted by: guabiik


    Hi, 

    i'm trying to use cplex in c. I'm using mingw. My version of cplex is 64 and mingw 32, i tried to donwload mingw 64 but i think it does not exists...

    I'm using one of the examples that cplex bring, but i have the following errors:

    Process started >>>
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x98): undefined reference to `_imp__CPXopenCPLEX@4'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xeb): undefined reference to `_imp__CPXgeterrorstring@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x12b): undefined reference to `_imp__CPXsetintparam@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x185): undefined reference to `_imp__CPXcreateprob@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x1f0): undefined reference to `_imp__CPXreadcopyprob@16'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x247): undefined reference to `_imp__CPXsetnodecallbackfunc@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x26b): undefined reference to `_imp__CPXsetbranchcallbackfunc@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x28f): undefined reference to `_imp__CPXsetsolvecallbackfunc@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x2c8): undefined reference to `_imp__CPXsetintparam@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x2f7): undefined reference to `_imp__CPXsetintparam@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x326): undefined reference to `_imp__CPXsetintparam@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x355): undefined reference to `_imp__CPXsetintparam@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x37b): undefined reference to `_imp__CPXmipopt@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x3c9): undefined reference to `_imp__CPXgetstat@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x3fd): undefined reference to `_imp__CPXgetobjval@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x45e): undefined reference to `_imp__CPXgetnumcols@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x4d6): undefined reference to `_imp__CPXgetx@20'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x589): undefined reference to `_imp__CPXfreeprob@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x5c9): undefined reference to `_imp__CPXcloseCPLEX@4'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x61c): undefined reference to `_imp__CPXgeterrorstring@12'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x794): undefined reference to `_imp__CPXgetcallbacknodelp@16'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x7cf): undefined reference to `_imp__CPXgetcallbackinfo@20'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x7f8): undefined reference to `_imp__CPXprimopt@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x814): undefined reference to `_imp__CPXdualopt@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x8a7): undefined reference to `_imp__CPXgetcallbacklp@16'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x8f4): undefined reference to `_imp__CPXgetnumcols@8'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0x9e4): undefined reference to `_imp__CPXgetcallbacknodex@24'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xa3f): undefined reference to `_imp__CPXgetcallbacknodeobjval@16'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xaa5): undefined reference to `_imp__CPXgetobj@20'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xb12): undefined reference to `_imp__CPXgetcallbacknodeintfeas@24'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xc95): undefined reference to `_imp__CPXbranchcallbackbranchbds@44'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xcfb): undefined reference to `_imp__CPXbranchcallbackbranchbds@44'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xd8d): undefined reference to `_imp__CPXgetcallbackinfo@20'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xddb): undefined reference to `_imp__CPXgetcallbacknodeinfo@24'
    C:\Users\Gabi\AppData\Local\Temp\cci1ikW7.o:cplex.c:(.text+0xe18): undefined reference to `_imp__CPXgetcallbacknodeinfo@24'
    collect2.exe: error: ld returned 1 exit status
    <<< Process finished. (Exit code 1)
    C:\Users\Gabi\Desktop\C\cplex.exe
    CreateProcess() failed with error code 2:
    El sistema no puede encontrar el archivo especificado.

     

    I use this to call cplex, but it does not work

    #include <C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h>

     

    I tried changing the PATH in windows for cplex, but nothing worked. 

    I triend with cplexx.h, but y have the following errors:

    cplex.c: In function 'main':
    cplex.c:103:8: warning: assignment makes pointer from integer without a cast [enabled by default]
        env = CPXopenCPLEX (&status);
            ^
    cplex.c:132:7: warning: assignment makes pointer from integer without a cast [enabled by default]
        lp = CPXcreateprob (env, &status, argv[nameind]);
           ^
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xb4): undefined reference to `CPXopenCPLEX'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x110): undefined reference to `CPXgeterrorstring'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x14d): undefined reference to `CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x1ba): undefined reference to `CPXcreateprob'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x234): undefined reference to `CPXreadcopyprob'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x292): undefined reference to `CPXsetnodecallbackfunc'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x2b5): undefined reference to `CPXsetbranchcallbackfunc'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x2d8): undefined reference to `CPXsetsolvecallbackfunc'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x318): undefined reference to `CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x34e): undefined reference to `CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x384): undefined reference to `CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x3ba): undefined reference to `CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x3eb): undefined reference to `CPXmipopt'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x444): undefined reference to `CPXgetstat'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x487): undefined reference to `CPXgetobjval'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x4f7): undefined reference to `CPXgetnumcols'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x58a): undefined reference to `CPXgetx'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x674): undefined reference to `CPXfreeprob'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x6c7): undefined reference to `CPXcloseCPLEX'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x723): undefined reference to `CPXgeterrorstring'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x893): undefined reference to `CPXgetcallbacknodelp'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x8c6): undefined reference to `CPXgetcallbackinfo'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x8ea): undefined reference to `CPXprimopt'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x901): undefined reference to `CPXdualopt'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x98f): undefined reference to `CPXgetcallbacklp'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0x9d7): undefined reference to `CPXgetnumcols'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xac2): undefined reference to `CPXgetcallbacknodex'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xb18): undefined reference to `CPXgetcallbacknodeobjval'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xb79): undefined reference to `CPXgetobj'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xbe1): undefined reference to `CPXgetcallbacknodeintfeas'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xd5f): undefined reference to `CPXbranchcallbackbranchbds'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xdc0): undefined reference to `CPXbranchcallbackbranchbds'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xe4d): undefined reference to `CPXgetcallbackinfo'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xe96): undefined reference to `CPXgetcallbacknodeinfo'
    C:\Users\Gabi\AppData\Local\Temp\ccY3V7nr.o:cplex.c:(.text+0xece): undefined reference to `CPXgetcallbacknodeinfo'
    collect2.exe: error: ld returned 1 exit status

     

     

    I also change the CPX for CPXX when i use cplexx.h, but still not worked.

    I don't know how to make it work.

    :)


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: trying to use Cplex with gcc

    Posted Wed January 06, 2016 12:27 PM

    Symbols like _imp__CPXopenCPLEX@4 are 32bit symbols. Since apparently you are building a 32bit application you will have to use 32bit CPLEX.

    So either get 64bit mingw or 32bit CPLEX.

    If you encounter further problems you may want to search this forum. There are various threads that discuss problems with mingw and CPLEX.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: trying to use Cplex with gcc

    Posted Wed January 06, 2016 12:35 PM

    Originally posted by: T_O


    I always use this version of MinGW, cplexx.h and I define _LP64 in the preprocessor. Works quite well.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: trying to use Cplex with gcc

    Posted Wed January 06, 2016 12:43 PM

    Originally posted by: guabiik


    I downloaded that version, but i think that the gcc version to downloaed is w32, or i saw that in the options and nothing with w64...or that is not the 32bit ???


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: trying to use Cplex with gcc

    Posted Wed January 06, 2016 12:58 PM

    Originally posted by: T_O


    You can just follow this link. It leads to the most recent version (5.3.0, 64-bit)


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: trying to use Cplex with gcc

    Posted Wed January 06, 2016 09:42 PM

    Originally posted by: guabiik


    Thanks a lot. 

    Know i have a new error message:

     

    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h:17:0,
                     from cplex.c:33:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cpxconst.h:189:13: error: size of array 'CPXSIZE_BITS_TEST1' is negative
     typedef int CPXSIZE_BITS_TEST1[1 + (int)sizeof(CPXSIZE) - (int)sizeof(size_t)];

     

     

    the problem is an example from cplex, so the rest of the problem should be ok.

    Cplex works fine if i call it from ampl, and gcc works fine for another program that i did.

     

    and thanks for helping me :D


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: trying to use Cplex with gcc

    Posted Thu January 07, 2016 01:08 AM

    Originally posted by: T_O


    As I wrote, you have to define _LP64, e.g. "gcc -D_LP64 ..."


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: trying to use Cplex with gcc

    Posted Fri January 08, 2016 03:30 PM

    Originally posted by: guabiik


    sorry, i know is a very amateur question, but i don't know how to use or define the preprocessor, like, what sould i put...


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: trying to use Cplex with gcc

    Posted Fri January 08, 2016 03:59 PM

    Originally posted by: T_O


    Please re-read my last post:

    gcc -D_LP64 ...


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: trying to use Cplex with gcc

    Posted Fri January 08, 2016 04:10 PM

    Originally posted by: guabiik


    sorry, i did the wrong question, because i tried that and didn't work. 

    is what else should i put in that sentence?

    sorry, is just i don't find examples or thinks like that


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: trying to use Cplex with gcc

    Posted Fri January 08, 2016 04:14 PM

    Originally posted by: T_O


    You could also try to add

    #DEFINE _LP64

    before the inclusion of cplexx.h in the C code.


    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: trying to use Cplex with gcc

    Posted Mon January 11, 2016 03:26 AM

    It might be easier to help if you if you posted the full compiler command line you are using as well as the full error message.


    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: trying to use Cplex with gcc

    Posted Tue January 12, 2016 01:49 PM

    Originally posted by: guabiik


    This is the code for the example socpex1.c in the cplex examples. I add it the 3 first rows and change ALL the CPX for CPXX taht i could find.
    
    
    #define _LP64
    #include <C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h>
    gcc-D_LP64
    
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    /* Shortcut for infinity. */
    #define INF CPX_INFBOUND
    
    /* Tolerance for testing KKT conditions. */
    #define TESTTOL 1e-9
    /* Tolerance for barrier convergence. */
    #define CONVTOL 1e-9
    
    /* Marks columns that are in cone constraint but not the cone head. */
    #define NOT_CONE_HEAD -1
    /* Marks variables that are not in any cone constraint. */
    #define NOT_IN_CONE   -2
    
    /* Structure that holds information about a single quadratic constraint.
     * Instances of this structure are used to read quadratic constraints one
     * by one using function getqconstr().
     */
    typedef struct {
       int    *lind;  /* Indices of linear coefficients. */
       double *lval;  /* Values of linear coefficients. */
       int    *qrow;  /* Row indices for quadratic coefficients. */
       int    *qcol;  /* Column indices for quadratic coefficients. */
       double *qval;  /* Values for quadratic coefficients. */
       double rhs;    /* Right-hand side of quadratic constraint. */
       int    lnz;    /* Number of valid entries in lind and lval. */
       int    qnz;    /* Number of valid entries in qrow, qcol and qval. */
       int    qcap;   /* Length (max number of elements) of lind and lval. */
       int    lcap;   /* Length (max number of elements) of qrow, qcol and qval. */
       char   sense;  /* Sense of quadratic constraint. */
    } qbuf_type;
    
    /* Initialize an instance of qbuf_type. */
    static void
    qbuf_init (qbuf_type *qbuf)
    {
       memset (qbuf, 0, sizeof (*qbuf));
    }
    
    /* Release an instance of qbuf_type that was previously initialized by
     * qbuf_init().
     */
    static void
    qbuf_clear (qbuf_type *qbuf)
    {
       if ( qbuf->lcap > 0 ) {
          free (qbuf->lind);
          free (qbuf->lval);
       }
       if ( qbuf->qcap > 0 ) {
          free (qbuf->qrow);
          free (qbuf->qcol);
          free (qbuf->qval);
       }
       memset (qbuf, 0, sizeof (*qbuf));
    }
    
    /* Read quadratic constraint number Q from LP and store it in qbuf.
     * The buffers in qbuf are expanded if they do not provide enough room
     * to store the constraint.
     * The function returns a true value on success and false if it fails.
     */
    static int
    getqconstr (CPXXCENVptr env, CPXXCLPptr lp, int q, qbuf_type *qbuf)
    {
       int ok = 0;
       int status;
       int linnz, linsurplus;
       int qnz, qsurplus;
       CPXXCHANNELptr errc;
    
       /* Get the channel for printing error messages. */
       if ( (status = CPXXgetchannels (env, NULL, NULL, &errc, NULL)) != 0 )
          goto TERMINATE;
    
       /* Call CPXgetqconstr() a first time with zero-length buffers to figure
        * how long the buffers must be.
        */
       status = CPXXgetqconstr (env, lp, &linnz, &qnz, NULL, NULL,
                               NULL, NULL, 0, &linsurplus,
                               NULL, NULL, NULL, 0, &qsurplus, q);
       if ( status != CPXXERR_NEGATIVE_SURPLUS )
          goto TERMINATE;
    
       /* Adjust buffers for linear coefficients if necessary.
        */
       if ( linsurplus < 0 && -linsurplus >= qbuf->lcap ) {
          int newcap = -linsurplus;
    
          if ( (qbuf->lind = realloc (qbuf->lind, newcap * sizeof (*qbuf->lind))) == NULL ||
               (qbuf->lval = realloc (qbuf->lval, newcap * sizeof (*qbuf->lval))) == NULL )
          {
             CPXXmsg (errc, "Out of memory!\n");
             goto TERMINATE;
          }
          qbuf->lcap = newcap;
       }
    
       /* Adjust buffers for quadratic coefficients if necessary.
        */
       if ( qsurplus < 0 && -qsurplus >= qbuf->qcap ) {
          int newcap = -qsurplus;
    
          if ( (qbuf->qcol = realloc (qbuf->qcol, newcap * sizeof (*qbuf->qcol))) == NULL ||
               (qbuf->qrow = realloc (qbuf->qrow, newcap * sizeof (*qbuf->qrow))) == NULL ||
               (qbuf->qval = realloc (qbuf->qval, newcap * sizeof (*qbuf->qval))) == NULL )
          {
             CPXXmsg (errc, "Out of memory!\n");
             goto TERMINATE;
          }
          qbuf->qcap = newcap;
       }
    
       /* Now all buffers in QBUF are long enough to store the constraint we
        * want to query. Copy the constraint into QBUF.
        */
       status = CPXXgetqconstr (env, lp, &qbuf->lnz, &qbuf->qnz, &qbuf->rhs,
                               &qbuf->sense,
                               qbuf->lind, qbuf->lval, qbuf->lcap, &linsurplus,
                               qbuf->qrow, qbuf->qcol, qbuf->qval, qbuf->qcap,
                               &qsurplus, q);
       if ( status != 0 )
          goto TERMINATE;
    
       ok = 1;
     TERMINATE:
       return ok;
    }
    
    /* CPLEX does not provide a function to directly get the dual multipliers
     * for second order cone constraint.
     * Example qcpdual.c illustrates how the dual multipliers for a
     * quadratic constraint can be computed from that constraint's slack.
     * However, for SOCP we can do something simpler: we can read those
     * multipliers directly from the dual slacks for the
     * cone head variables. For a second order cone constraint
     *    x[1] >= |(x[2], ..., x[n])|
     * the dual multiplier is the dual slack value for x[1].
     */
    static int
    getsocpconstrmultipliers (CPXXCENVptr env, CPXXCLPptr lp,
                              double *dslack, double *socppi)
    {
       int status = 0;
       int const cols = CPXXgetnumcols (env, lp);
       int const qs = CPXXgetnumqconstrs (env, lp);
       double *dense = NULL, *val = NULL;
       int *ind = NULL;
       int j, q;
       qbuf_type qbuf;
    
       qbuf_init (&qbuf);
    
       if ( (dense = malloc (sizeof (*dense) * cols)) == NULL ) {
          status = CPXXERR_NO_MEMORY;
          goto TERMINATE;
       }
    
       /* First of all get the dual slack vector. This is the sum of
        * dual multipliers for bound constraints (as returned by CPXgetdj())
        * and the per-constraint dual slack vectors (as returned by
        * CPXgetqconstrdslack()).
        */
    
       /* Get dual multipliers for bound constraints. */
       if ( (status = CPXXgetdj (env, lp, dense, 0, cols - 1)) != 0 )
          goto TERMINATE;
    
       /* Create a dense vector that holds the sum of dual slacks for all
        * quadratic constraints.
        */
       if ( (val = malloc (cols * sizeof (val))) == NULL ||
            (ind = malloc (cols * sizeof (ind))) == NULL )
       {
          status = CPXXERR_NO_MEMORY;
          goto TERMINATE;
       }
       for (q = 0; q < qs; ++q) {
          int len = 0, surp;
    
          if ( (status = CPXXgetqconstrdslack (env, lp, q, &len, ind, val,
                                              cols, &surp)) != 0 )
             goto TERMINATE;
          for (j = 0; j < len; ++j) {
             dense[ind[j]] += val[j];
          }
       }
    
       /* Now go through the socp constraints. For each constraint find the
        * cone head variable (the one variable that has a negative coefficient)
        * and pick up its dual slack. This is the dual multiplier for the
        * constraint.
        */
       for (q = 0; q < qs; ++q) {
          if ( !getqconstr (env, lp, q, &qbuf) ) {
             status = CPXXERR_BAD_ARGUMENT;
             goto TERMINATE;
          }
          for (j = 0; j < qbuf.qnz; ++j) {
             if ( qbuf.qval[j] < 0.0 ) {
                /* This is the cone head variable. */
                socppi[q] = dense[qbuf.qcol[j]];
                break;
             }
          }
       }
    
       /* If the caller wants to have the dual slack vector then copy it
        * to the output array.
        */
       if ( dslack != NULL )
          memcpy (dslack, dense, sizeof (*dslack) * cols);
    
     TERMINATE:
       free (ind);
       free (val);
       free (dense);
    
       qbuf_clear (&qbuf);
    
       return status;
    }
    
    /*
     * The function returns a true value if the tested KKT conditions are
     * satisfied and false otherwise.
     */
    static int
    checkkkt (CPXXCENVptr env, CPXXLPptr lp, int const *cone, double tol)
    {
       int cols = CPXXgetnumcols (env, lp);
       int rows = CPXXgetnumrows (env, lp);
       int qcons = CPXXgetnumqconstrs (env, lp);
       double *dslack = NULL, *pi = NULL, *socppi = NULL;
       double *val = NULL, *rhs = NULL;
       int *ind = NULL;
       char *sense = NULL;
       double *x = NULL, *slack = NULL, *qslack = NULL;
       double *sum = NULL;
       qbuf_type qbuf;
       CPXXCHANNELptr resc, warnc, errc, logc;
       int ok = 0, skip = 0;
       int status;
       int i, j, q;
    
       qbuf_init (&qbuf);
    
       /* Get the channels on which we may report. */
       if ( (status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc)) != 0 )
          goto TERMINATE;
    
       /* Fetch results and problem data that we need to check the KKT
        * conditions.
        */
       CPXXmsg (logc, "Fetching results ... ");
       if ( (cols  > 0 && (dslack = malloc (cols *  sizeof (*dslack))) == NULL) ||
            (rows  > 0 && (pi =     malloc (rows *  sizeof (*pi)))     == NULL) ||
            (qcons > 0 && (socppi = malloc (qcons * sizeof (*socppi))) == NULL) ||
            (cols  > 0 && (x =      malloc (cols *  sizeof (*x)))      == NULL) ||
            (rows  > 0 && (sense =  malloc (rows *  sizeof (*sense)))  == NULL ) ||
            (rows  > 0 && (slack =  malloc (rows *  sizeof (*slack)))  == NULL ) ||
            (qcons > 0 && (qslack = malloc (qcons * sizeof (*qslack))) == NULL) ||
            (cols  > 0 && (sum =    malloc (cols *  sizeof (*sum)))    == NULL) ||
            (cols  > 0 && (val =    malloc (cols *  sizeof (*val)))    == NULL) ||
            (cols  > 0 && (ind =    malloc (cols *  sizeof (*ind)))    == NULL) ||
            (rows  > 0 && (rhs =    malloc (rows *  sizeof (*rhs)))    == NULL) )
       {
          CPXXmsg (errc, "Out of memory!\n");
          goto TERMINATE;
       }
    
       /* Fetch problem data. */
       if ( (status = CPXXgetsense (env, lp, sense, 0, rows - 1)) != 0 )
          goto TERMINATE;
       if ( (status = CPXXgetrhs (env, lp, rhs, 0, rows - 1)) != 0 )
          goto TERMINATE;
    
       /* Fetch solution information. */
       if ( (status = CPXXgetx (env, lp, x, 0, cols - 1)) != 0 )
          goto TERMINATE;
       if ( (status = CPXXgetpi (env, lp, pi, 0, rows - 1)) != 0 )
          goto TERMINATE;
       if ( (status = getsocpconstrmultipliers (env, lp, dslack, socppi)) != 0 )
          goto TERMINATE;
       if ( (status = CPXXgetslack (env, lp, slack, 0, rows - 1)) != 0 )
          goto TERMINATE;
       if ( (status = CPXXgetqconstrslack (env, lp, qslack, 0, qcons - 1)) != 0 )
          goto TERMINATE;
       CPXXmsg (logc, "ok.\n");
    
       /* Print out the solution data we just fetched. */
       CPXXmsg (resc, "x      = [");
       for (j = 0; j < cols; ++j)
          CPXXmsg (resc, " %+7.3f", x[j]);
       CPXXmsg (resc, " ]\n");
       CPXXmsg (resc, "dslack = [");
       for (j = 0; j < cols; ++j)
          CPXXmsg (resc, " %+7.3f", dslack[j]);
       CPXXmsg (resc, " ]\n");
       CPXXmsg (resc, "pi     = [");
       for (i = 0; i < rows; ++i)
          CPXXmsg (resc, " %+7.3f", pi[i]);
       CPXXmsg (resc, " ]\n");
       CPXXmsg (resc, "slack  = [");
       for (i = 0; i < rows; ++i)
          CPXXmsg (resc, " %+7.3f", slack[i]);
       CPXXmsg (resc, " ]\n");
       CPXXmsg (resc, "socppi = [");
       for (q = 0; q < qcons; ++q)
          CPXXmsg (resc, " %+7.3f", socppi[q]);
       CPXXmsg (resc, " ]\n");
       CPXXmsg (resc, "qslack = [");
       for (q = 0; q < qcons; ++q)
          CPXXmsg (resc, " %+7.3f", qslack[q]);
       CPXXmsg (resc, " ]\n");
    
       /* Test primal feasibility. */
       CPXXmsg (logc, "Testing primal feasibility ... ");
       /* This example illustrates the use of dual vectors returned by CPLEX
        * to verify dual feasibility, so we do not test primal feasibility
        * here. */
       CPXXmsg (logc, "ok.\n");
    
       /* Test dual feasibility.
        * We must have
        * - for all <= constraints the respective pi value is non-negative,
        * - for all >= constraints the respective pi value is non-positive,
        * - since all quadratic constraints are <= constraints the socppi
        *   value must be non-negative for all quadratic constraints,
        * - the dslack value for all non-cone variables must be non-negative.
        * Note that we do not support ranged constraints here.
        */
       CPXXmsg (logc, "Testing dual feasibility ... ");
       for (i = 0; i < rows; ++i) {
          switch (sense[i]) {
          case 'L':
             if ( pi[i] < -tol ) {
                CPXXmsg (errc, "<= row %d has invalid dual multiplier %f.\n",
                        i, pi[i]);
                goto TERMINATE;
             }
             break;
          case 'G':
             if ( pi[i] > tol ) {
                CPXXmsg (errc, ">= row %d has invalid dual multiplier %f.\n",
                        i, pi[i]);
                goto TERMINATE;
             }
             break;
          case 'E':
             /* Nothing to check here. */
             break;
          }
       }
       for (q = 0; q < qcons; ++q) {
          if ( socppi[q] < -tol ) {
             CPXXmsg (errc, "Quadratic constraint %d has invalid dual multiplier %f.\n",
                     q, socppi[q]);
             goto TERMINATE;
          }
       }
       for (j = 0; j < cols; ++j) {
          if ( cone[j] == NOT_IN_CONE && dslack[j] < -tol ) {
             CPXXmsg (errc, "dslack value for column %d is invalid: %f\n", j, dslack[j]);
             goto TERMINATE;
          }
       }
       CPXXmsg (logc, "ok.\n");
    
       /* Test complementary slackness.
        * For each constraint either the constraint must have zero slack or
        * the dual multiplier for the constraint must be 0. Again, we must
        * consider the special case in which a variable is not explicitly
        * contained in a second order cone constraint (conestat[j] == 0).
        */
       CPXXmsg (logc, "Testing complementary slackness ... ");
       for (i = 0; i < rows; ++i) {
          if ( fabs (slack[i]) > tol && fabs (pi[i]) > tol ) {
             CPXXmsg (errc, "Complementary slackness not satisfied for row %d (%f, %f)\n",
                     i, slack[i], pi[i]);
             goto TERMINATE;
          }
       }
       for (q = 0; q < qcons; ++q) {
          if ( fabs (qslack[q]) > tol && fabs (socppi[q]) > tol ) {
             CPXXmsg (errc, "Complementary slackness not satisfied for cone %d (%f, %f).\n",
                     q, qslack[q], socppi[q]);
             goto TERMINATE;
          }
       }
       for (j = 0; j < cols; ++j) {
          if ( cone[j] == NOT_IN_CONE ) {
             if ( fabs (x[j]) > tol && fabs (dslack[j]) > tol ) {
                CPXXmsg (errc, "Complementary slackness not satisfied for non-cone variable %f (%f, %f).\n",
                        j, x[j], dslack[j]);
                goto TERMINATE;
             }
          }
       }
       CPXXmsg (logc, "ok.\n");
    
       /* Test stationarity.
        * We must have
        *  c - g[i]'(X)*pi[i] = 0
        * where c is the objective function, g[i] is the i-th constraint of the
        * problem, g[i]'(x) is the derivate of g[i] with respect to x and X is the
        * optimal solution.
        * We need to distinguish the following cases:
        * - linear constraints g(x) = ax - b. The derivative of such a
        *   constraint is g'(x) = a.
        * - second order constraints g(x[1],...,x[n]) = -x[1] + |(x[2],...,x[n])|
        *   the derivative of such a constraint is
        *     g'(x) = (-1, x[2]/|(x[2],...,x[n])|, ..., x[n]/|(x[2],...,x[n])|
        *   (here |.| denotes the Euclidean norm).
        * - bound constraints g(x) = -x for variables that are not explicitly
        *   contained in any second order cone constraint. The derivative for
        *   such a constraint is g'(x) = -1.
        * Note that it may happen that the derivative of a second order cone
        * constraint is not defined at the optimal solution X (this happens if
        * X=0). In this case we just skip the stationarity test.
        */
       CPXXmsg (logc, "Testing stationarity ... ");
       /* Initialize sum = c. */
       if ( (status = CPXXgetobj (env, lp, sum, 0, cols - 1)) != 0 )
          goto TERMINATE;
    
       /* Handle linear constraints. */
       for (i = 0; i < rows; ++i) {
          int nz, surplus, beg;
          int n;
    
          status = CPXXgetrows (env, lp, &nz, &beg, ind, val, cols, &surplus,
                               i, i);
          if ( status != 0 )
             goto TERMINATE;
          for (n = 0; n < nz; ++n) {
             sum[ind[n]] -= pi[i] * val[n];
          }
       }
       /* Handle second order cone constraints. */
       for (q = 0; q < qcons; ++q) {
          double norm = 0.0;
          int n;
    
          if ( !getqconstr (env, lp, q, &qbuf) )
             goto TERMINATE;
    
          for (n = 0; n < qbuf.qnz; ++n) {
             if ( qbuf.qval[n] > 0 )
                norm += x[qbuf.qcol[n]] * x[qbuf.qcol[n]];
          }
          norm = sqrt (norm);
          if ( fabs (norm) <= tol ) {
             CPXXmsg (warnc, "WARNING: Cannot test stationarity at non-differentiable point.\n");
             skip = 1;
             break;
          }
    
          for (n = 0; n < qbuf.qnz; ++n) {
             if ( qbuf.qval[n] < 0 )
                sum[qbuf.qcol[n]] -= socppi[q];
             else
                sum[qbuf.qcol[n]] += socppi[q] * x[qbuf.qcol[n]] / norm;
          }
       }
       /* Handle variables that do not appear in any second order cone constraint.
        */
       for (j = 0; !skip && j < cols; ++j) {
          if ( cone[j] == NOT_IN_CONE ) {
             sum[j] -= dslack[j];
          }
       }
    
       /* Now test that all the entries in sum[] are 0.
        */
       for (j = 0; !skip && j < cols; ++j) {
          if ( fabs (sum[j]) > tol ) {
             CPXXmsg (errc, "Stationarity not satisfied at index %d: %f\n",
                     j, sum[j]);
             goto TERMINATE;
          }
       }
       CPXXmsg (logc, "ok.\n");
    
       CPXXmsg (logc, "KKT conditions are satisfied.\n");
    
       ok = 1;
     TERMINATE:
       if ( !ok )
          CPXXmsg (logc, "failed.\n");
       qbuf_clear (&qbuf);
       free (rhs);
       free (ind);
       free (val);
       free (sum);
       free (qslack);
       free (slack);
       free (sense);
       free (x);
       free (socppi);
       free (pi);
       free (dslack);
    
       return ok;
    }
    
    /* This function creates the following model:
     *   Minimize
     *    obj: x1 + x2 + x3 + x4 + x5 + x6
     *   Subject To
     *    c1: x1 + x2      + x5      = 8
     *    c2:           x3 + x5 + x6 = 10
     *    q1: [ -x1^2 + x2^2 + x3^2 ] <= 0
     *    q2: [ -x4^2 + x5^2 ] <= 0
     *   Bounds
     *    x2 Free
     *    x3 Free
     *    x5 Free
     *   End
     * which is a second order cone program in standard form.
     * The function returns a true value on success and false on error.
     * The function also sets up *cone_p as follows:
     * (*cone_p)[j] >= 0              Column j is contained in a cone constraint
     *                                and is the cone head variable of that
     *                                constraint. The index of the respective
     *                                quadratic constraint is given by (*cone_p)[j].
     * (*cone_p)[j] = NOT_CONE_HEAD   Column j is contained in a cone constraint
     *                                but is not the cone head variable of that
     *                                constraint.
     * (*cone_p)[j] = NOT_IN_CONE     Column j is not contained in any cone
     *                                constraint.
     */
    static int
    createmodel (CPXXENVptr env, CPXXLPptr lp, int **cone_p)
    {
       /* Column data. */
       static double const obj[]        = {  1.0,  1.0,  1.0,  1.0,  1.0,  1.0 };
       static double const lb[]         = {  0.0, -INF, -INF,  0.0, -INF,  0.0 };
       static double const ub[]         = {  INF,  INF,  INF,  INF,  INF,  INF };
       static char const *const cname[] = { "x1", "x2", "x3", "x4", "x5", "x6" };
    
       /* Row data. */
       static double const rval[]       = { 1.0, 1.0, 1.0,    1.0, 1.0, 1.0 };
       static int const rind[]          = {   0,   1,   4,      2,   4,   5 };
       static int const rbeg[]          = {   0,                3           };
       static double const rhs[]        = { 8.0,             10.0           };
       static char const sense[]        = { 'E',              'E'           };
       static char const *const rname[] = { "c1",             "c2"          };
    
       /* Data for second order cone constraints. */
       static double const qval[]  = { -1.0, 1.0, 1.0 }; /* Same for all Q cons. */
       static double const qrhs    = 0.0;                /* Same for all Q cons. */
       static char const qsense    = 'L';                /* Same for all Q cons. */
       static int const qind1[] = { 0, 1, 2 };
       static int const qind2[] = { 3, 4 };
    
       int status;
       int ok = 0;
       int *cone = NULL;
    
       CPXXCHANNELptr errc;
    
       /* Get the channel for printing error messages. */
       if ( (status = CPXXgetchannels (env, NULL, NULL, &errc, NULL)) != 0 )
          goto TERMINATE;
    
       cone = malloc ((sizeof (obj) / sizeof (obj[0])) * sizeof (*cone));
       if ( cone == NULL ) {
          CPXXmsg (errc, "Out of memory!\n");
          goto TERMINATE;
       }
    
       status = CPXXchgobjsen (env, lp, CPXX_MIN);
       if ( status != 0 )
          goto TERMINATE;
    
       status = CPXXnewcols (env, lp, sizeof (obj) / sizeof (obj[0]),
                            obj, lb, ub, NULL, (char **)cname);
       if ( status != 0 )
          goto TERMINATE;
    
       status = CPXXaddrows (env, lp, 0, sizeof (rhs) / sizeof (rhs[0]),
                            sizeof (rval) / sizeof (rval[0]), rhs, sense,
                            rbeg, rind, rval, NULL, (char **)rname);
       if ( status != 0 )
          goto TERMINATE;
    
       status = CPXXaddqconstr (env, lp, 0, sizeof (qind1) / sizeof (qind1[0]),
                               qrhs, qsense, NULL, NULL,
                               qind1, qind1, qval, "q1");
       if ( status != 0 )
          goto TERMINATE;
       cone[0] = 0;
       cone[1] = NOT_CONE_HEAD;
       cone[2] = NOT_CONE_HEAD;
       status = CPXXaddqconstr (env, lp, 0, sizeof (qind2) / sizeof (qind2[0]),
                               qrhs, qsense, NULL, NULL,
                               qind2, qind2, qval, "q2");
       if ( status != 0 )
          goto TERMINATE;
       cone[3] = 1;
       cone[4] = NOT_CONE_HEAD;
    
       cone[5] = NOT_IN_CONE;
    
       ok = 1;
     TERMINATE:
       if ( !ok )
          free (cone);
    
       *cone_p = cone;
    
       return ok;
    }
    
    int
    main (void)
    {
       CPXXENVptr env;
       CPXXLPptr lp = NULL;
       int *cone = NULL;
       int status;
       CPXXCHANNELptr resc, warnc, errc, logc;
       int retval = -1;
    
       /* Initialize CPLEX and get a reference to the output channels.
        * If any of this fails immediately terminate the program.
        */
       env = CPXXopenCPLEX (&status);
       if ( env == NULL || status != 0 )
          abort ();
    
       status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
       if ( status != 0 )
          abort ();
    
       /* CPLEX is fully setup. Enable output.
        */
       status = CPXXsetintparam (env, CPXPARAM_ScreenOutput, CPX_ON);
       if ( status != 0 )
          goto TERMINATE;
    
       /* Create model. */
       lp = CPXXcreateprob (env, &status, "xsocpex1");
       if ( lp == NULL || status != 0 )
          goto TERMINATE;
       if ( !createmodel (env, lp, &cone) )
          goto TERMINATE;
    
       /* Solve the problem to optimality. */
       CPXXmsg (logc, "Optimizing ...\n");
       status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
       if ( status != 0 )
          goto TERMINATE;
       if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
          goto TERMINATE;
    
       if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
          CPXXmsg (errc, "Cannot test KKT conditions on non-optimal solution.\n");
          goto TERMINATE;
       }
    
       /* Now test KKT conditions on the result. */
       if ( !checkkkt (env, lp, cone, TESTTOL) ) {
          CPXXmsg (logc, "Testing of KKT conditions failed.\n");
          CPXXmsg (errc, "Testing of KKT conditions failed.\n");
          goto TERMINATE;
       }
    
       CPXXmsg (resc, "KKT conditions are satisfied.\n");
       retval = 0;
     TERMINATE:
       free (cone);
       if ( lp != NULL )
          CPXXfreeprob (env, &lp);
       CPXXcloseCPLEX (&env);
    
       return retval;
    }
    

    And all the errors are:

     

    cplex2.c:3:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token
     gcc-D_LP64
        ^
    cplex2.c:72:13: error: unknown type name 'CPXXCENVptr'
     getqconstr (CPXXCENVptr env, CPXXCLPptr lp, int q, qbuf_type *qbuf)
                 ^
    cplex2.c:72:30: error: unknown type name 'CPXXCLPptr'
     getqconstr (CPXXCENVptr env, CPXXCLPptr lp, int q, qbuf_type *qbuf)
                                  ^
    cplex2.c:149:27: error: unknown type name 'CPXXCENVptr'
     getsocpconstrmultipliers (CPXXCENVptr env, CPXXCLPptr lp,
                               ^
    cplex2.c:149:44: error: unknown type name 'CPXXCLPptr'
     getsocpconstrmultipliers (CPXXCENVptr env, CPXXCLPptr lp,
                                                ^
    cplex2.c:237:11: error: unknown type name 'CPXXCENVptr'
     checkkkt (CPXXCENVptr env, CPXXLPptr lp, int const *cone, double tol)
               ^
    cplex2.c:237:28: error: unknown type name 'CPXXLPptr'
     checkkkt (CPXXCENVptr env, CPXXLPptr lp, int const *cone, double tol)
                                ^
    cplex2.c:542:14: error: unknown type name 'CPXXENVptr'
     createmodel (CPXXENVptr env, CPXXLPptr lp, int **cone_p)
                  ^
    cplex2.c:542:30: error: unknown type name 'CPXXLPptr'
     createmodel (CPXXENVptr env, CPXXLPptr lp, int **cone_p)
                                  ^
    cplex2.c: In function 'main':
    cplex2.c:627:4: error: unknown type name 'CPXXENVptr'
        CPXXENVptr env;
        ^
    cplex2.c:628:4: error: unknown type name 'CPXXLPptr'
        CPXXLPptr lp = NULL;
        ^
    cplex2.c:628:19: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
        CPXXLPptr lp = NULL;
                       ^
    cplex2.c:631:4: error: unknown type name 'CPXXCHANNELptr'
        CPXXCHANNELptr resc, warnc, errc, logc;
        ^
    cplex2.c:637:8: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        env = CPXXopenCPLEX (&status);
            ^
    cplex2.c:638:13: warning: comparison between pointer and integer
        if ( env == NULL || status != 0 )
                 ^
    cplex2.c:641:30: warning: passing argument 1 of 'CPXXgetchannels' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:35: warning: passing argument 2 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                       ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:42: warning: passing argument 3 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                              ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:50: warning: passing argument 4 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                                      ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:57: warning: passing argument 5 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                                             ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:647:30: warning: passing argument 1 of 'CPXXsetintparam' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXsetintparam (env, CPXPARAM_ScreenOutput, CPX_ON);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2011:4: note: expected 'CPXENVptr {aka struct cpxenv *}' but argument is of type 'int'
        CPXXsetintparam (CPXENVptr env, int whichparam, CPXINT newvalue)
        ^
    cplex2.c:652:25: warning: passing argument 1 of 'CPXXcreateprob' makes pointer from integer without a cast [-Wint-conversion]
        lp = CPXXcreateprob (env, &status, "xsocpex1");
                             ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:521:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXcreateprob (CPXCENVptr env, int *status_p,
        ^
    cplex2.c:652:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        lp = CPXXcreateprob (env, &status, "xsocpex1");
           ^
    cplex2.c:653:12: warning: comparison between pointer and integer
        if ( lp == NULL || status != 0 )
                ^
    cplex2.c:655:10: warning: implicit declaration of function 'createmodel' [-Wimplicit-function-declaration]
        if ( !createmodel (env, lp, &cone) )
              ^
    cplex2.c:659:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Optimizing ...\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:660:35: error: 'CPXXPARAM_Barrier_QCPConvergeTol' undeclared (first use in this function)
        status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
                                       ^
    cplex2.c:660:35: note: each undeclared identifier is reported only once for each function it appears in
    cplex2.c:660:30: warning: passing argument 1 of 'CPXXsetdblparam' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1995:4: note: expected 'CPXENVptr {aka struct cpxenv *}' but argument is of type 'int'
        CPXXsetdblparam (CPXENVptr env, int whichparam, double newvalue)
        ^
    cplex2.c:663:43: error: 'CPXX_ALG_NONE' undeclared (first use in this function)
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                               ^
    cplex2.c:663:34: warning: passing argument 1 of 'CPXXhybbaropt' makes pointer from integer without a cast [-Wint-conversion]
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                      ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2303:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXhybbaropt (CPXCENVptr env, CPXLPptr lp, int method)
        ^
    cplex2.c:663:39: warning: passing argument 2 of 'CPXXhybbaropt' makes pointer from integer without a cast [-Wint-conversion]
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                           ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2303:4: note: expected 'CPXLPptr {aka struct cpxlp *}' but argument is of type 'int'
        CPXXhybbaropt (CPXCENVptr env, CPXLPptr lp, int method)
        ^
    cplex2.c:666:22: warning: passing argument 1 of 'CPXXgetstat' makes pointer from integer without a cast [-Wint-conversion]
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                          ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1457:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXgetstat (CPXCENVptr env, CPXCLPptr lp)
        ^
    cplex2.c:666:27: warning: passing argument 2 of 'CPXXgetstat' makes pointer from integer without a cast [-Wint-conversion]
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                               ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1457:4: note: expected 'CPXCLPptr {aka const struct cpxlp *}' but argument is of type 'int'
        CPXXgetstat (CPXCENVptr env, CPXCLPptr lp)
        ^
    cplex2.c:666:34: error: 'CPXX_STAT_OPTIMAL' undeclared (first use in this function)
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                                      ^
    cplex2.c:667:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Cannot test KKT conditions on non-optimal solution.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:672:10: warning: implicit declaration of function 'checkkkt' [-Wimplicit-function-declaration]
        if ( !checkkkt (env, lp, cone, TESTTOL) ) {
              ^
    cplex2.c:673:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (logc, "Testing of KKT conditions failed.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:674:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Testing of KKT conditions failed.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:678:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "KKT conditions are satisfied.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:682:12: warning: comparison between pointer and integer
        if ( lp != NULL )
                ^
    cplex2.c:683:21: warning: passing argument 1 of 'CPXXfreeprob' makes pointer from integer without a cast [-Wint-conversion]
           CPXXfreeprob (env, &lp);
                         ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:814:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXfreeprob (CPXCENVptr env, CPXLPptr *lp_p)
        ^
    cplex2.c:683:26: warning: passing argument 2 of 'CPXXfreeprob' from incompatible pointer type [-Wincompatible-pointer-types]
           CPXXfreeprob (env, &lp);
                              ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:814:4: note: expected 'struct cpxlp **' but argument is of type 'int *'
        CPXXfreeprob (CPXCENVptr env, CPXLPptr *lp_p)
        ^
    cplex2.c:684:20: warning: passing argument 1 of 'CPXXcloseCPLEX' from incompatible pointer type [-Wincompatible-pointer-types]
        CPXXcloseCPLEX (&env);
                        ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:382:4: note: expected 'struct cpxenv **' but argument is of type 'int *'
        CPXXcloseCPLEX (CPXENVptr *env_p)
        ^

     

    Is a bit long all the things, sorry


    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: trying to use Cplex with gcc

    Posted Tue January 12, 2016 02:59 PM

    Try removing the line 'gcc-D_LP64', it is bogus.

    What Thomas meant was that you should put '-D_LP64' on the command line (and not into the source file) when invoking gcc.


    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: trying to use Cplex with gcc

    Posted Tue January 12, 2016 03:09 PM

    Originally posted by: guabiik


    I have tried also removing the 'gcc-...' line, but the errors are the same :

    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:17:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cpxconst.h:189:13: error: size of array 'CPXSIZE_BITS_TEST1' is negative
     typedef int CPXSIZE_BITS_TEST1[1 + (int)sizeof(CPXSIZE) - (int)sizeof(size_t)];
                 ^
    cplex2.c:72:13: error: unknown type name 'CPXXCENVptr'
     getqconstr (CPXXCENVptr env, CPXXCLPptr lp, int q, qbuf_type *qbuf)
                 ^
    cplex2.c:72:30: error: unknown type name 'CPXXCLPptr'
     getqconstr (CPXXCENVptr env, CPXXCLPptr lp, int q, qbuf_type *qbuf)
                                  ^
    cplex2.c:149:27: error: unknown type name 'CPXXCENVptr'
     getsocpconstrmultipliers (CPXXCENVptr env, CPXXCLPptr lp,
                               ^
    cplex2.c:149:44: error: unknown type name 'CPXXCLPptr'
     getsocpconstrmultipliers (CPXXCENVptr env, CPXXCLPptr lp,
                                                ^
    cplex2.c:237:11: error: unknown type name 'CPXXCENVptr'
     checkkkt (CPXXCENVptr env, CPXXLPptr lp, int const *cone, double tol)
               ^
    cplex2.c:237:28: error: unknown type name 'CPXXLPptr'
     checkkkt (CPXXCENVptr env, CPXXLPptr lp, int const *cone, double tol)
                                ^
    cplex2.c:542:14: error: unknown type name 'CPXXENVptr'
     createmodel (CPXXENVptr env, CPXXLPptr lp, int **cone_p)
                  ^
    cplex2.c:542:30: error: unknown type name 'CPXXLPptr'
     createmodel (CPXXENVptr env, CPXXLPptr lp, int **cone_p)
                                  ^
    cplex2.c: In function 'main':
    cplex2.c:627:4: error: unknown type name 'CPXXENVptr'
        CPXXENVptr env;
        ^
    cplex2.c:628:4: error: unknown type name 'CPXXLPptr'
        CPXXLPptr lp = NULL;
        ^
    cplex2.c:628:19: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
        CPXXLPptr lp = NULL;
                       ^
    cplex2.c:631:4: error: unknown type name 'CPXXCHANNELptr'
        CPXXCHANNELptr resc, warnc, errc, logc;
        ^
    cplex2.c:637:8: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        env = CPXXopenCPLEX (&status);
            ^
    cplex2.c:638:13: warning: comparison between pointer and integer
        if ( env == NULL || status != 0 )
                 ^
    cplex2.c:641:30: warning: passing argument 1 of 'CPXXgetchannels' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:35: warning: passing argument 2 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                       ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:42: warning: passing argument 3 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                              ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:50: warning: passing argument 4 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                                      ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:641:57: warning: passing argument 5 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc);
                                                             ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:647:30: warning: passing argument 1 of 'CPXXsetintparam' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXsetintparam (env, CPXPARAM_ScreenOutput, CPX_ON);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2011:4: note: expected 'CPXENVptr {aka struct cpxenv *}' but argument is of type 'int'
        CPXXsetintparam (CPXENVptr env, int whichparam, CPXINT newvalue)
        ^
    cplex2.c:652:25: warning: passing argument 1 of 'CPXXcreateprob' makes pointer from integer without a cast [-Wint-conversion]
        lp = CPXXcreateprob (env, &status, "xsocpex1");
                             ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:521:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXcreateprob (CPXCENVptr env, int *status_p,
        ^
    cplex2.c:652:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        lp = CPXXcreateprob (env, &status, "xsocpex1");
           ^
    cplex2.c:653:12: warning: comparison between pointer and integer
        if ( lp == NULL || status != 0 )
                ^
    cplex2.c:655:10: warning: implicit declaration of function 'createmodel' [-Wimplicit-function-declaration]
        if ( !createmodel (env, lp, &cone) )
              ^
    cplex2.c:659:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Optimizing ...\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:660:35: error: 'CPXXPARAM_Barrier_QCPConvergeTol' undeclared (first use in this function)
        status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
                                       ^
    cplex2.c:660:35: note: each undeclared identifier is reported only once for each function it appears in
    cplex2.c:660:30: warning: passing argument 1 of 'CPXXsetdblparam' makes pointer from integer without a cast [-Wint-conversion]
        status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
                                  ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1995:4: note: expected 'CPXENVptr {aka struct cpxenv *}' but argument is of type 'int'
        CPXXsetdblparam (CPXENVptr env, int whichparam, double newvalue)
        ^
    cplex2.c:663:43: error: 'CPXX_ALG_NONE' undeclared (first use in this function)
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                               ^
    cplex2.c:663:34: warning: passing argument 1 of 'CPXXhybbaropt' makes pointer from integer without a cast [-Wint-conversion]
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                      ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2303:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXhybbaropt (CPXCENVptr env, CPXLPptr lp, int method)
        ^
    cplex2.c:663:39: warning: passing argument 2 of 'CPXXhybbaropt' makes pointer from integer without a cast [-Wint-conversion]
        if ( (status = CPXXhybbaropt (env, lp, CPXX_ALG_NONE)) != 0 )
                                           ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2303:4: note: expected 'CPXLPptr {aka struct cpxlp *}' but argument is of type 'int'
        CPXXhybbaropt (CPXCENVptr env, CPXLPptr lp, int method)
        ^
    cplex2.c:666:22: warning: passing argument 1 of 'CPXXgetstat' makes pointer from integer without a cast [-Wint-conversion]
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                          ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1457:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXgetstat (CPXCENVptr env, CPXCLPptr lp)
        ^
    cplex2.c:666:27: warning: passing argument 2 of 'CPXXgetstat' makes pointer from integer without a cast [-Wint-conversion]
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                               ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1457:4: note: expected 'CPXCLPptr {aka const struct cpxlp *}' but argument is of type 'int'
        CPXXgetstat (CPXCENVptr env, CPXCLPptr lp)
        ^
    cplex2.c:666:34: error: 'CPXX_STAT_OPTIMAL' undeclared (first use in this function)
        if ( CPXXgetstat (env, lp) != CPXX_STAT_OPTIMAL ) {
                                      ^
    cplex2.c:667:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Cannot test KKT conditions on non-optimal solution.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:672:10: warning: implicit declaration of function 'checkkkt' [-Wimplicit-function-declaration]
        if ( !checkkkt (env, lp, cone, TESTTOL) ) {
              ^
    cplex2.c:673:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (logc, "Testing of KKT conditions failed.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:674:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Testing of KKT conditions failed.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:678:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "KKT conditions are satisfied.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:2:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:682:12: warning: comparison between pointer and integer
        if ( lp != NULL )
                ^
    cplex2.c:683:21: warning: passing argument 1 of 'CPXXfreeprob' makes pointer from integer without a cast [-Wint-conversion]
           CPXXfreeprob (env, &lp);
                         ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:814:4: note: expected 'CPXCENVptr {aka const struct cpxenv *}' but argument is of type 'int'
        CPXXfreeprob (CPXCENVptr env, CPXLPptr *lp_p)
        ^
    cplex2.c:683:26: warning: passing argument 2 of 'CPXXfreeprob' from incompatible pointer type [-Wincompatible-pointer-types]
           CPXXfreeprob (env, &lp);
                              ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:814:4: note: expected 'struct cpxlp **' but argument is of type 'int *'
        CPXXfreeprob (CPXCENVptr env, CPXLPptr *lp_p)
        ^
    cplex2.c:684:20: warning: passing argument 1 of 'CPXXcloseCPLEX' from incompatible pointer type [-Wincompatible-pointer-types]
        CPXXcloseCPLEX (&env);
                        ^
    In file included from cplex2.c:2:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:382:4: note: expected 'struct cpxenv **' but argument is of type 'int *'
        CPXXcloseCPLEX (CPXENVptr *env_p)
        ^

     

    I had the gcc included in the console of notepad++, so i can run it in a simpler way, so, thats wrong?


    #CPLEXOptimizers
    #DecisionOptimization


  • 16.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 02:28 AM

    Two things:

    1.  Your source code is wrong. There are no types like CPXXENVptr and CPXXLPptr. Even in the CPX-API, these types are called CPXENVptr and CPXLPptr (only one 'X' in the type name). The error message "cplex2.c:72:13: error: unknown type name 'CPXXCENVptr'" clearly states that. Fixing up these type names in your code should get rid of most of the errors.
    2. About the very first error, does it help to
         #define CPXSIZE_BITS 64
      before including cplexx.h?

    Are you now using the same version of mingw as Thomas? It would seem odd if you have to manually define CPXSIZE_BITS while Thomas has not.


    #CPLEXOptimizers
    #DecisionOptimization


  • 17.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 11:20 AM

    Originally posted by: guabiik


    For the very first error is now ok, thanks! and yes, i am using the same version as Thomas.

    and i change the CPXXENVptr and CPXXLPptr, and all the "undeclared" variables back to CPX, and not CPXX. 

    This are my new error messages:

     

     

    cplex2.c: In function 'getqconstr':
    cplex2.c:82:19: warning: implicit declaration of function 'CPXgetchannels' [-Wimplicit-function-declaration]
        if ( (status = CPXgetchannels (env, NULL, NULL, &errc, NULL)) != 0 )
                       ^
    cplex2.c:88:46: warning: passing argument 4 of 'CPXXgetqconstr' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetqconstr (env, lp, &linnz, &qnz, NULL, NULL,
                                                  ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2430:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetqconstr (CPXCENVptr env, CPXCLPptr lp, CPXDIM *linnzcnt_p,
        ^
    cplex2.c:90:49: warning: passing argument 15 of 'CPXXgetqconstr' from incompatible pointer type [-Wincompatible-pointer-types]
                                NULL, NULL, NULL, 0, &qsurplus, q);
                                                     ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2430:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetqconstr (CPXCENVptr env, CPXCLPptr lp, CPXDIM *linnzcnt_p,
        ^
    cplex2.c:126:50: warning: passing argument 4 of 'CPXXgetqconstr' from incompatible pointer type [-Wincompatible-pointer-types]
        status = CPXXgetqconstr (env, lp, &qbuf->lnz, &qbuf->qnz, &qbuf->rhs,
                                                      ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2430:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetqconstr (CPXCENVptr env, CPXCLPptr lp, CPXDIM *linnzcnt_p,
        ^
    cplex2.c:130:28: warning: passing argument 15 of 'CPXXgetqconstr' from incompatible pointer type [-Wincompatible-pointer-types]
                                &qsurplus, q);
                                ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:2430:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetqconstr (CPXCENVptr env, CPXCLPptr lp, CPXDIM *linnzcnt_p,
        ^
    cplex2.c: In function 'getsocpconstrmultipliers':
    cplex2.c:164:16: error: 'CPXXERR_NO_MEMORY' undeclared (first use in this function)
           status = CPXXERR_NO_MEMORY;
                    ^
    cplex2.c:164:16: note: each undeclared identifier is reported only once for each function it appears in
    cplex2.c:205:19: error: 'CPXXERR_BAD_ARGUMENT' undeclared (first use in this function)
              status = CPXXERR_BAD_ARGUMENT;
                       ^
    cplex2.c: In function 'checkkkt':
    cplex2.c:250:4: error: unknown type name 'CPXXCHANNELptr'
        CPXXCHANNELptr resc, warnc, errc, logc;
        ^
    cplex2.c:258:41: warning: passing argument 2 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        if ( (status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc)) != 0 )
                                             ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:258:48: warning: passing argument 3 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        if ( (status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc)) != 0 )
                                                    ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:258:56: warning: passing argument 4 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        if ( (status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc)) != 0 )
                                                            ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:258:63: warning: passing argument 5 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        if ( (status = CPXXgetchannels (env, &resc, &warnc, &errc, &logc)) != 0 )
                                                                   ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:264:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Fetching results ... ");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:277:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Out of memory!\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:298:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "ok.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:301:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "x      = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:303:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", x[j]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:304:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:305:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "dslack = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:307:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", dslack[j]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:308:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:309:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "pi     = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:311:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", pi[i]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:312:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:313:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "slack  = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:315:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", slack[i]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:316:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:317:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "socppi = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:319:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", socppi[q]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:320:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:321:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, "qslack = [");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:323:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (resc, " %+7.3f", qslack[q]);
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:324:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (resc, " ]\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:327:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Testing primal feasibility ... ");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:331:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "ok.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:342:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Testing dual feasibility ... ");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:347:22: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
                 CPXXmsg (errc, "<= row %d has invalid dual multiplier %f.\n",
                          ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:354:22: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
                 CPXXmsg (errc, ">= row %d has invalid dual multiplier %f.\n",
                          ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:366:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (errc, "Quadratic constraint %d has invalid dual multiplier %f.\n",
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:373:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (errc, "dslack value for column %d is invalid: %f\n", j, dslack[j]);
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:377:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "ok.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:385:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Testing complementary slackness ... ");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:388:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (errc, "Complementary slackness not satisfied for row %d (%f, %f)\n",
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:395:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (errc, "Complementary slackness not satisfied for cone %d (%f, %f).\n",
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:403:22: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
                 CPXXmsg (errc, "Complementary slackness not satisfied for non-cone variable %f (%f, %f).\n",
                          ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:409:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "ok.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:431:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "Testing stationarity ... ");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:441:38: warning: passing argument 3 of 'CPXXgetrows' from incompatible pointer type [-Wincompatible-pointer-types]
           status = CPXXgetrows (env, lp, &nz, &beg, ind, val, cols, &surplus,
                                          ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1394:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetrows (CPXCENVptr env, CPXCLPptr lp, CPXNNZ *nzcnt_p,
        ^
    cplex2.c:441:43: warning: passing argument 4 of 'CPXXgetrows' from incompatible pointer type [-Wincompatible-pointer-types]
           status = CPXXgetrows (env, lp, &nz, &beg, ind, val, cols, &surplus,
                                               ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1394:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetrows (CPXCENVptr env, CPXCLPptr lp, CPXNNZ *nzcnt_p,
        ^
    cplex2.c:441:65: warning: passing argument 8 of 'CPXXgetrows' from incompatible pointer type [-Wincompatible-pointer-types]
           status = CPXXgetrows (env, lp, &nz, &beg, ind, val, cols, &surplus,
                                                                     ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1394:4: note: expected 'CPXNNZ * {aka long long int *}' but argument is of type 'int *'
        CPXXgetrows (CPXCENVptr env, CPXCLPptr lp, CPXNNZ *nzcnt_p,
        ^
    cplex2.c:463:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (warnc, "WARNING: Cannot test stationarity at non-differentiable point.\n");
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:487:19: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
              CPXXmsg (errc, "Stationarity not satisfied at index %d: %f\n",
                       ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:492:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "ok.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:494:13: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
        CPXXmsg (logc, "KKT conditions are satisfied.\n");
                 ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:499:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (logc, "failed.\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c: In function 'createmodel':
    cplex2.c:570:4: error: unknown type name 'CPXXCHANNELptr'
        CPXXCHANNELptr errc;
        ^
    cplex2.c:573:53: warning: passing argument 4 of 'CPXXgetchannels' from incompatible pointer type [-Wincompatible-pointer-types]
        if ( (status = CPXXgetchannels (env, NULL, NULL, &errc, NULL)) != 0 )
                                                         ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:881:4: note: expected 'struct cpxchannel **' but argument is of type 'int *'
        CPXXgetchannels (CPXCENVptr env, CPXCHANNELptr *cpxresults_p,
        ^
    cplex2.c:578:16: warning: passing argument 1 of 'CPXLmsg' makes pointer from integer without a cast [-Wint-conversion]
           CPXXmsg (errc, "Out of memory!\n");
                    ^
    In file included from C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:43:0,
                     from cplex2.c:3:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexl.h:1106:4: note: expected 'CPXCHANNELptr {aka struct cpxchannel *}' but argument is of type 'int'
        CPXLmsg (CPXCHANNELptr channel, char const *format, ...);
        ^
    cplex2.c:582:37: error: 'CPXX_MIN' undeclared (first use in this function)
        status = CPXXchgobjsen (env, lp, CPXX_MIN);
                                         ^
    cplex2.c:587:44: warning: passing argument 8 of 'CPXXnewcols' from incompatible pointer type [-Wincompatible-pointer-types]
                             obj, lb, ub, NULL, (char **)cname);
                                                ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:1698:4: note: expected 'const char * const*' but argument is of type 'char **'
        CPXXnewcols (CPXCENVptr env, CPXLPptr lp, CPXDIM ccnt,
        ^
    cplex2.c:593:25: warning: passing argument 8 of 'CPXXaddrows' from incompatible pointer type [-Wincompatible-pointer-types]
                             rbeg, rind, rval, NULL, (char **)rname);
                             ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:147:4: note: expected 'const CPXNNZ * {aka const long long int *}' but argument is of type 'const int *'
        CPXXaddrows (CPXCENVptr env, CPXLPptr lp, CPXDIM ccnt, CPXDIM rcnt,
        ^
    cplex2.c:593:49: warning: passing argument 12 of 'CPXXaddrows' from incompatible pointer type [-Wincompatible-pointer-types]
                             rbeg, rind, rval, NULL, (char **)rname);
                                                     ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplexx.h:147:4: note: expected 'const char * const*' but argument is of type 'char **'
        CPXXaddrows (CPXCENVptr env, CPXLPptr lp, CPXDIM ccnt, CPXDIM rcnt,
        ^
    cplex2.c: In function 'main':
    cplex2.c:661:35: error: 'CPXXPARAM_Barrier_QCPConvergeTol' undeclared (first use in this function)
        status = CPXXsetdblparam (env, CPXXPARAM_Barrier_QCPConvergeTol, CONVTOL);
                                       ^


    #CPLEXOptimizers
    #DecisionOptimization


  • 18.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 11:31 AM

    Some of these errors you should be able to fix yourself. For example

    • warning: implicit declaration of function 'CPXgetchannels': Since you included cplexx.h, only the CPXX functions are defined. You need to use CPXXgetchannels() here (two 'X')
    • error: unknown type name 'CPXXCHANNELptr': same as in my previous post: The type name only has a single 'X'.

    The remaining errors seem to come from the fact that you are using the CPXX-API with types like 'int'. The CPXX-API is designed to be used with the more specific CPXDIM, CPXNNZ, etc. types. In order to get things going I suggest to do the following:

    1. Include cplex.h instead of cplexx.h
    2. Replace CPXX by CPX everywhere in your code

    Does this work any better?


    #CPLEXOptimizers
    #DecisionOptimization


  • 19.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 11:43 AM

    Originally posted by: guabiik


    i think it works better, i have new kinds of errors :D  

     

    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x100): undefined reference to `__imp_CPXgetchannels'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x197): undefined reference to `__imp_CPXgetqconstr'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x24e): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x33c): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x400): undefined reference to `__imp_CPXgetqconstr'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x464): undefined reference to `__imp_CPXgetnumcols'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x47b): undefined reference to `__imp_CPXgetnumqconstrs'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x4f5): undefined reference to `__imp_CPXgetdj'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x5a5): undefined reference to `__imp_CPXgetqconstrdslack'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x7c3): undefined reference to `__imp_CPXgetnumcols'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x7e0): undefined reference to `__imp_CPXgetnumrows'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x7fd): undefined reference to `__imp_CPXgetnumqconstrs'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x8c6): undefined reference to `__imp_CPXgetchannels'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x8ea): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xad1): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xb0a): undefined reference to `__imp_CPXgetsense'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xb4b): undefined reference to `__imp_CPXgetrhs'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xb8c): undefined reference to `__imp_CPXgetx'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xbcd): undefined reference to `__imp_CPXgetpi'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xc45): undefined reference to `__imp_CPXgetslack'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xc86): undefined reference to `__imp_CPXgetqconstrslack'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xcaa): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xcc1): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xd19): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xd3c): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xd53): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0xdab): more undefined references to `__imp_CPXmsg' follow
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x16af): undefined reference to `__imp_CPXgetobj'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1726): undefined reference to `__imp_CPXgetrows'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1936): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1bdb): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1c0d): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1c24): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1c6f): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1d79): undefined reference to `__imp_CPXgetchannels'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1db2): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1dd1): undefined reference to `__imp_CPXchgobjsen'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1e2c): undefined reference to `__imp_CPXnewcols'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1eb2): undefined reference to `__imp_CPXaddrows'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1f3d): undefined reference to `__imp_CPXaddqconstr'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x1fee): undefined reference to `__imp_CPXaddqconstr'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2094): undefined reference to `__imp_CPXopenCPLEX'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x20d2): undefined reference to `__imp_CPXgetchannels'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x20fc): undefined reference to `__imp_CPXsetintparam'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2125): undefined reference to `__imp_CPXcreateprob'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2177): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2198): undefined reference to `__imp_CPXsetdblparam'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x21c0): undefined reference to `__imp_CPXhybbaropt'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x21e2): undefined reference to `__imp_CPXgetstat'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x21fe): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2241): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2258): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x2271): undefined reference to `__imp_CPXmsg'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x22ad): undefined reference to `__imp_CPXfreeprob'
    C:\Users\Gabi\AppData\Local\Temp\ccKOR5Ll.o:cplex2.c:(.text+0x22bd): undefined reference to `__imp_CPXcloseCPLEX'
    collect2.exe: error: ld returned 1 exit status


    #CPLEXOptimizers
    #DecisionOptimization


  • 20.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 11:43 AM

    Originally posted by: T_O


    You have to link the CPLEX library.


    #CPLEXOptimizers
    #DecisionOptimization


  • 21.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 12:06 PM

    Originally posted by: guabiik


    But, how you do it? i tried adding cplex to the  PATH  in my windows, but nothing


    #CPLEXOptimizers
    #DecisionOptimization


  • 22.  Re: trying to use Cplex with gcc

    Posted Wed January 13, 2016 03:07 PM

    Originally posted by: T_O


    Go to the folder where cplexXXXX.dll is located (XXXX specifies the version number, I guess it is 1261 in your case). For me this is cplex\bin\x64_win64 in the CPLEX installation directory. Run

    gendef.exe cplexXXXX.dll

    and

    dlltool --output-lib libcplexXXXX.a --input-def cplexXXXX.def --dllname=cplexXXXX.dll

    (you can also copy cplexXXXX.dll to some other folder and do it there).

    Then use the GCC parameter -L to specify the folder where the new libcplexXXXX.a is located. Use the parameter -l to link against it, e.g. -lcplexXXXX . Please read a gcc tutorial to find out about the correct order of these parameters (and other basic knowledge about gcc). The order is important!

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization


  • 23.  Re: trying to use Cplex with gcc

    Posted Thu January 14, 2016 01:18 PM

    Originally posted by: guabiik


    I don't have the gendef.exe in my CPLEX installation directory 

    and "

    dlltool --output-lib libcplexXXXX.a --input-def cplexXXXX.def --dllname=cplexXXXX.dll

    i have to put it in my code? or how do i use it?


    #CPLEXOptimizers
    #DecisionOptimization


  • 24.  Re: trying to use Cplex with gcc

    Posted Thu January 14, 2016 01:23 PM

    Originally posted by: T_O


    Both tools are included in the MinGW distribution that I linked above.


    #CPLEXOptimizers
    #DecisionOptimization


  • 25.  Re: trying to use Cplex with gcc

    Posted Fri January 15, 2016 10:56 AM

    Originally posted by: guabiik


    So...i found everything, i write it like this:

    #define _LP64
    #define CPXSIZE_BITS 64
    #include <C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h>
    
    gendef.exe cplex1261.dll
    dlltool --output-lib libcplexXXXX.a --input-def cplexXXXX.def --dllname=cplexXXXX.dll
    

    but i have this error:

    #define _LP64
    #define CPXSIZE_BITS 64
    #include <C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h>

    gendef.exe cplex1261.dll
    dlltool --output-lib libcplexXXXX.a --input-def cplexXXXX.def --dllname=cplexXXXX.dll

    ,

    i also tried with an #include but i have 

    ex1.c:6:38: warning: extra tokens at end of #include directive
     #include <C:/mingw64/bin/gendef.exe> <C:/Program File/IBM/ILOG/CPLEX_Studio1261/cplex/bin/x64_win64/cplex1261.dll>
                                          ^
     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 26.  Re: trying to use Cplex with gcc

    Posted Fri January 15, 2016 11:00 AM

    Originally posted by: T_O


    ???

    Don't I understand your post or did you add my shell commands to your C file? If yes: Please learn the basics how a computer works. If no: Sorry, pleas explain again.


    #CPLEXOptimizers
    #DecisionOptimization