coin-or / Osi

Open Solver Interface
Other
54 stars 41 forks source link

Issue compiling OsiCpxSolverInterface in MSYS2 / MinGW64 / Windows #174

Closed WvA1979 closed 1 year ago

WvA1979 commented 1 year ago

I am using MSYS2 MINGW64 to compile various projects. One of these projects has a COIN dependency and notably uses OsiCpx ; Now i have managed to get everything compiled except for OsiCpx where the difficulty resides in specifying the cplex location ;

This may have to do with cplex being installed in "Program Files" ;

My base command (without OsiCpx getting compiled) : wget https://raw.githubusercontent.com/coin-or/coinbrew/v1.0/coinbrew ./coinbrew fetch Clp ./coinbrew build Clp ADD_FFLAGS=-fallow-argument-mismatch ADD_LT_LDFLAGS=-lstdc++ --tests=none

works fine and after some hours everything is there ;

However when I do: wget https://raw.githubusercontent.com/coin-or/coinbrew/v1.0/coinbrew ./coinbrew fetch Clp ./coinbrew build Clp ADD_FFLAGS=-fallow-argument-mismatch ADD_LT_LDFLAGS=-lstdc++ --tests=none --with-cplex --with-cplex-lib="/c/Program Files/IBM/ILOG/CPLEX_Studio221/cplex/lib/x64_windows_msvc14/stat_mda/cplex2210.lib" --with-cplex-incdir="/c/Program Files/IBM/ILOG/CPLEX_Studio221/cplex/include/ilcplex/" --disable-cplex-libcheck

issues appear in the configure script in the Osi/Osi directory lines 23272 where CPXINCDIR is set ; (I have tried specifying the space with \ and with or without "" ) in fact here I get

**checking if user provides library for Cplex... ./configure: line 23272: cd: too many arguments
yes
configure: error: Cannot find file cplex.h in /c/LocalDriveD/Tools/ExtLibs/coin/Osi/Osi
configure: error: /bin/sh './configure' failed for Osi**

I have tried a dirty workaround by skipping this and just setting manually the directories, in other words changing these lines to:

# Check whether --with-cplex-incdir or --without-cplex-incdir was given.
#if test "${with_cplex_incdir+set}" = set; then
#  withval="$with_cplex_incdir"
#  CPXINCDIR=`cd $withval; pwd`
#fi;
CPXINCDIR=/c/Program\ Files/IBM/ILOG/CPLEX_Studio221/cplex/include/ilcplex/

# Check for library directory

# Check whether --with-cplex-lib or --without-cplex-lib was given.
#if test "${with_cplex_lib+set}" = set; then
#  withval="$with_cplex_lib"
#  CPXLIB=$withval
#fi;
CPXLIB=/c/Program\ Files/IBM/ILOG/CPLEX_Studio221/cplex/lib/x64_windows_msvc14/stat_mda/cplex2210.lib

Then indeed I can manually configure, yet "make" still fails:

**Making all in src/OsiCpx
make[2]: Entering directory '/c/LocalDriveD/Tools/ExtLibs/coin/Osi/Osi/src/OsiCpx'
/bin/sh ../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../../src/Osi  -I`echo /c/Program Files/IBM/ILOG/CPLEX_Studio221/cplex/include/ilcplex/` -I`echo ./../Osi` -IC:/LocalDriveD/Tools/ExtLibs/coin/dist/include/coin    -O3 -pipe -DNDEBUG -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long   -DOSI_BUILD -c -o OsiCpxSolverInterface.lo OsiCpxSolverInterface.cpp
 g++ -DHAVE_CONFIG_H -I. -I. -I../../src/Osi -I/c/Program Files/IBM/ILOG/CPLEX_Studio221/cplex/include/ilcplex/ -I./../Osi -IC:/LocalDriveD/Tools/ExtLibs/coin/dist/include/coin -O3 -pipe -DNDEBUG -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -DOSI_BUILD -c OsiCpxSolverInterface.cpp -o OsiCpxSolverInterface.o
OsiCpxSolverInterface.cpp:22:10: fatal error: cplex.h: No such file or directory
   22 | #include "cplex.h"
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:471: OsiCpxSolverInterface.lo] Error 1
make[2]: Leaving directory '/c/LocalDriveD/Tools/ExtLibs/coin/Osi/Osi/src/OsiCpx'
make[1]: *** [Makefile:533: all-recursive] Error 1
make[1]: Leaving directory '/c/LocalDriveD/Tools/ExtLibs/coin/Osi/Osi'
make: *** [Makefile:324: all-recursive] Error 1**

I am making an attempt after having put cplex in a directory without "white spaces", but unsure if that will do the trick ; Is there any proper way of handling the problem ?

svigerske commented 1 year ago

Try copying the CPLEX header and libs into a directory which names doesn't have spaces. Spaces in paths don't work well with configure and makefiles.

WvA1979 commented 1 year ago

Indeed if CPLEX is in a path without spaces it compiles : The correct command is then:

./coinbrew build Clp ADD_FFLAGS=-fallow-argument-mismatch ADD_LT_LDFLAGS=-lstdc++ --tests=none --with-cplex --with-cplex-lib=/c/IBM/ILOG/CPLEX_Studio221/cplex/lib/x64_windows_msvc14/stat_mda/cplex2210.lib --with-cplex-incdir=/c/IBM/ILOG/CPLEX_Studio221/cplex/include/ilcplex/ --disable-cplex-libcheck ADD_CXXFLAGS="-DBUILD_CPXSTATIC -DCPXSIZE_BITS_TEST_DISABLE"

The additional CXXFLAGS are necessary for Cplex deprecation issues ; Likewise the FFLAGS are necessary for the third party code