0

I'm trying to use cplexAPI C++ in a CLion project with C++11 on Windows 10. I have looked at several posts related to this question (e.g. config CMakeLists.txt, install MinG64) and I have managed to configure my CMakeLists.txt in the following way:

cmake_minimum_required(VERSION 3.15)
project(VRP_PRP)

add_executable(VRP_PRP main.cpp held-karp.h held-karp.cpp)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -m64 -O -fPIC -fexceptions -DNDEBUG -DIL_STD -std=c++11")

include_directories(/biblio/cplex/include/)
include_directories(/biblio/cplex/include/ilcplex)
include_directories(/biblio/concert/include)
include_directories(/biblio/concert/include/ilconcert)

target_link_libraries(VRP_PRP PUBLIC /biblio/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib)
target_link_libraries(VRP_PRP PUBLIC /biblio/cplex/lib/x64_windows_msvc14/stat_mda/ilocplex.lib)
target_link_libraries(VRP_PRP PUBLIC /biblio/concert/lib/x64_windows_msvc14/stat_mda/concert.lib)

target_link_libraries(VRP_PRP PUBLIC "-lilocplex -lconcert -lcplex -lm -lpthread")

it happens that when building my project it throws the following errors:

[ 33%] Linking CXX executable VRP_PRP.exe
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lilocplex
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lconcert
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [CMakeFiles\VRP_PRP.dir\build.make:105: VRP_PRP.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:75: CMakeFiles/VRP_PRP.dir/all] Error 2
mingw32-make.exe: *** [Makefile:83: all] Error 2

and by including the libraries (#include <ilcplex/ilocplex.h>) in my main.cpp it can't find them.

I have tried using 2 ways to link libraries in my CMakeLists.txt:

a) #set (target_link_options "-lilocplex -lconcert -lcplex -lm -lpthread -framework CoreFoundation -framework IOKit -std=c++11")

b) #target_link_libraries(VRP_PRP PUBLIC "-lilocplex -lconcert -lcplex -lm -lpthread")

Any help or idea will be appreciated.

Thanks.

afdez
  • 89
  • 7
  • 1
    Does this answer your question? [C++: Cplex/cp optimizer makefile issues on project build using Clion with MinGW and g++ compiler](https://stackoverflow.com/questions/61021096/c-cplex-cp-optimizer-makefile-issues-on-project-build-using-clion-with-mingw) – rkersh Apr 10 '20 at 17:51
  • Hi @rkersh, thanks for your answer. I have the same error with 'ilosys.h, line 26', I read that link and I see the problem, but how I fix that in window? – afdez Apr 11 '20 at 00:20
  • The "fix" is to use the Microsoft Visual C++ compiler (i.e., use Visual Studio 2015 or later). If you want to use `g++` then you'll have to do it on Linux where it is supported. You could consider using the [WSL](https://learn.microsoft.com/en-us/windows/wsl/faq) as well. – rkersh Apr 11 '20 at 17:18
  • @rkresh that's right!, thanks so much! – afdez Apr 28 '20 at 13:24

1 Answers1

1

My solution.

I installed Visual Studio 2017 Community together with CPLEX 12.9 Academic Version, then I opened the examples which is in:

C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\examples

and they already come with the configuration done.

afdez
  • 89
  • 7