Skip to content

[BUG] Simple QP example in C not compiling #757

@mtanneau

Description

@mtanneau

Describe the bug

The simple_qp_example.c example fails to compile.
I obtain the following error message:

docs/cuopt/source/cuopt-c/lp-milp/examples/simple_qp_example.c: In function 'test_simple_qp':
docs/cuopt/source/cuopt-c/lp-milp/examples/simple_qp_example.c:133:40: error: passing argument 16 of 'cuOptCreateQuadraticProblem' from incompatible pointer type [-Wincompatible-pointer-types]
  133 |                                        variable_types,
      |                                        ^~~~~~~~~~~~~~
      |                                        |
      |                                        char *
In file included from docs/cuopt/source/cuopt-c/lp-milp/examples/simple_qp_example.c:25:
~/miniconda3/envs/cuopt_dev/include/cuopt/linear_programming/cuopt_c.h:311:29: note: expected 'void **' but argument is of type 'char *'
  311 |   cuOptOptimizationProblem* problem_ptr);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
docs/cuopt/source/cuopt-c/lp-milp/examples/simple_qp_example.c:118:12: error: too many arguments to function 'cuOptCreateQuadraticProblem'
  118 |   status = cuOptCreateQuadraticProblem(num_constraints,
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
~/miniconda3/envs/cuopt_dev/include/cuopt/linear_programming/cuopt_c.h:295:13: note: declared here
  295 | cuopt_int_t cuOptCreateQuadraticProblem(
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Note that the error occurs because the call to cuOptCreateQuadraticProblem should not include variable types (i.e. continuous vs integer vs binary) here:

Steps/Code to reproduce bug

  • Checkout main branch
  • Build cuopt from source
  • Compile
    gcc -I . -L . -o simple_qp docs/cuopt/source/cuopt-c/lp-milp/examples/simple_qp_example.c -lcuopt

Expected behavior

The example should compile without error, and the executable should execute as expected.

Environment details (please complete the following information):

  • Environment location: DGX Spark workstation
  • Method of cuOpt install: from source using conda (via miniconda as specified in official instructions)

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

awaiting responseThis expects a response from maintainer or contributor depending on who requested in last comment.bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions