1

I have been sent code for a program built in C that uses a reinforcement learning algorithm. I need to modify it, yet I am having difficulties with compiling the code in the first place. Here are the outputs in CodeBlocks.

All errors come from one line of code in a header file, which is part of the IBM CPLEX include directory (include\cplex\cpxconst.h)

The line of code in question is as follows.

define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)

error messages are multiple types of syntax errors such as: error: expected identifier or '(' before ')' token

Each error has notes: to multiple lines of code in the file ilcplex\cplex.h

I am using CodeBlocks in Windows 10 CPLEX version is 12.9.0

FULL ERROR MESSAGE

||=== Build: Release in SWEM2020 (compiler: GNU GCC Compiler) ===| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\swemextras.h|16|error: conflicting types for 'trunc'| c:\mingw\include\math.h|820|note: previous declaration of 'trunc' was here| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1194|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1200|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_genetic1.c||In function 'GeneticAlgorithm1':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_genetic1.c|64|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_genetic1.c|67|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\dlist.c|137|error: conflicting types for 'InsertInOrder_dlist'| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\dlist.h|19|note: previous declaration of 'InsertInOrder_dlist' was here| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1231|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1237|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1242|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected ')' before 'deprecated'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cpxconst.h|243|error: expected identifier or '(' before ')' token| C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\include\ilcplex\cplex.h|1597|note: in expansion of macro 'CPXDEPRECATEDAPI'| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\swemextras.h|16|error: conflicting types for 'trunc'| c:\mingw\include\math.h|820|note: previous declaration of 'trunc' was here| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'RFAlgorithm1':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|183|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|185|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'Alg_MERwFirms_MustRun':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|466|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'Alg_MERwFirms':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|727|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|729|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'Alg_MERwFirmsSoftmax':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|934|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|936|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'Alg_ERSpilloverwFirms':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1179|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1181|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'Alg_ERSpilloverwFirmsSoftmax':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1393|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1395|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'RFAlgorithm':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1573|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1575|warning: unused variable 'lostLoad' [-Wunused-variable]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c||In function 'RFAlgorithmM':| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1784|warning: too many arguments for format [-Wformat-extra-args]| C:\Users\Tingle\OneDrive\Documents\Coding\SWEM2020\alg_rf.c|1786|warning: unused variable 'lostLoad' [-Wunused-variable]| ||=== Build failed: 27 error(s), 17 warning(s) (0 minute(s), 2 second(s)) ===|

  • What operating system are you on? What version of CPLEX? Can you show a more complete error message? – rkersh Apr 13 '20 at 13:43
  • I have added the complete error message. I am using CodeBlocks in Windows 10 CPLEX version is 12.9.0, compiling in MinGW. – Ginger Slice Apr 13 '20 at 23:19

1 Answers1

2

This answer is very similar to the one I gave here: C++: Cplex/cp optimizer makefile issues on project build using Clion with MinGW and g++ compiler

The CPLEX detailed system requirements (click on "Version 12.9.0" > "Windows" > "Prerequisites") show that Visual Studio 2015-2019 are the only supported compilers on Windows.

If we look at cpxconst.h, line 243 (from your error message), code in question we see:

#   if defined(_WIN32) && !defined(BUILD_CPXSTATIC)
#      define CPXLIBAPI __declspec(dllimport)
#      define CPXDEPRECATEDAPI(version) __declspec(dllimport deprecated)
#      define CPXDEPRECATED(version) __declspec(deprecated)
...
#   endif

Based on this, it looks like your MinGW gcc has _WIN32 defined and it's defining CPXDEPRECATEDAPI in such a way that is only compatible with Microsoft Visual C.

You could replace the definition of CPXDEPRECATEDAPI with a no-op (i.e., edit cpxconst.h, like so:

#      define CPXDEPRECATEDAPI(version)

However, you are likely to just end up running into some other error down the line.

On Windows, you should really just use Visual Studio 2015 or above, or perhaps consider using the WSL.

rkersh
  • 4,447
  • 2
  • 22
  • 31
  • 2
    You can compile bindings on mingw-w64 by adding `-DBUILD_CPXSTATIC` to the compiler flags. – Jeroen Ooms Dec 01 '20 at 13:58
  • (For CPLEX 20.10): Besides the @JeroenOoms 's tip, I had to also define `-DCPXSIZE_BITS_TEST_DISABLE`. Without this flag, the compiler outputs an error in `cpxconst.h:185` that tests for uint64 size. – José Joaquim Jul 08 '22 at 16:06