coin-or / Bonmin

Basic Open-source Nonlinear Mixed INteger programming
https://coin-or.github.io/Bonmin
Eclipse Public License 1.0
118 stars 22 forks source link

Building Bonmin with Cplex on Windows using WSL #3

Closed CJNeumann closed 5 years ago

CJNeumann commented 5 years ago

I am trying to build Bonmin with Cplex on Windows using WSL (ubuntu) using the process described here.

Setting up third party tools and steps 1-3 run through smoothly but than I obtain an error in Step 4 executing the make command:

/mnt/c/Bonmin-1.8.7/build/ThirdParty/Blas/.libs/libcoinblas.so: undefined reference tod_imag' /mnt/c/Bonmin-1.8.7/build/ThirdParty/Blas/.libs/libcoinblas.so: undefined reference to d_sign' collect2: error: ld returned 1 exit status Makefile:833: recipe for target 'clp' failed

I've attached both the output of the make file as well as the config.log. Thanks for following up on this one!

config.log

make_output.txt

andrescodas commented 5 years ago

Hi!. I'm not familiar with WSL, but if it helps, here I post an excerpt of a Dockerfile I use to build Bonmin with Cplex and other libraries.

WORKDIR "${ROOT_DIR}/dependencies/cplex/"
RUN chmod a+x cplex_studio12.7.1.linux-x86-64.bin \
 && ./cplex_studio12.7.1.linux-x86-64.bin -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR="${CPLEX}"

## INSTALL HSL

WORKDIR "${ROOT_DIR}/dependencies/hsl/"
RUN unzip coinhsl-archive-2014.01.17.zip \
 && mkdir -p "${HSL_PATH}" \
 && cd "${HSL_PATH}" \
 && "${ROOT_DIR}/dependencies/hsl/coinhsl-archive-2014.01.17/configure" --prefix="${HSL_PATH}" \
 && make; make install; make clean \
 && find . -not -name '.' | grep -v ./include | grep -v ./lib | xargs rm -rf ; rm libtool \
 && cd "${ROOT_DIR}/dependencies/hsl/" \
 && rm -rf "${ROOT_DIR}/dependencies/hsl/coinhsl-archive-2014.01.17" \
#
# test hsl installation
 && pkg-config --libs coinhsl \
#
# remove all the installers of the dependencies
 && rm -rf "${ROOT_DIR}/dependencies"

# install BONMIN
WORKDIR "${ROOT_DIR}/"
RUN mkdir -p "${ROOT_DIR}/coin/" \
 && svn co https://projects.coin-or.org/svn/Bonmin/releases/"${BONMIN_RELEASE}"/ bonmin_src \
 && cd "${ROOT_DIR}/bonmin_src/ThirdParty/ASL/" \
 && ./get.ASL \
 && cd "${ROOT_DIR}/bonmin_src/ThirdParty/Blas/" \
 && ./get.Blas \
 && cd "${ROOT_DIR}/bonmin_src/ThirdParty/Lapack/" \
 && ./get.Lapack \
 && cd "${ROOT_DIR}/bonmin_src/ThirdParty/Metis/" \
 && ./get.Metis \
 && cd "${ROOT_DIR}/bonmin_src/ThirdParty/Mumps/" \
 && ./get.Mumps \
 && cd "${ROOT_DIR}/bonmin_src/" \
 && mkdir build \
 && cd "${ROOT_DIR}/bonmin_src/build" \
 && ../configure --prefix="${ROOT_DIR}/coin/" \
                 --with-hsl-lib="-L${HSL_PATH}/lib/ -lcoinhsl" --with-hsl-incdir="${HSL_PATH}/include/" \
                 --with-cplex-lib="${CPLEX}/cplex/lib/x86-64_linux/static_pic/libcplex.a -lpthread -lm" --with-cplex-incdir="${CPLEX}/cplex/include/ilcplex" \
                 ADD_FFLAGS=-fPIC ADD_CFLAGS=-fPIC ADD_CXXFLAGS=-fPIC \
#
 && make; make install \
 && cd "${ROOT_DIR}" \
 && rm -rf bonmin_src \
#
# Test if pkg-config is able to find your Bonmin installation:
&& pkg-config --libs bonmin ipopt
CJNeumann commented 5 years ago

Thanks Andres! I stuck to WSL and building worked using the coinbrew-script and the command

bash coinbrew build Bonmin --with-cplex-lib="-L /opt/ibm/ILOG/CPLEX_Studio129/cplex/lib/x86-64_linux/static_pic -lcplex -ldl -lm -lpthread" --with-cplex-incdir=/opt/ibm/ILOG/CPLEX_Studio129/cplex/include/ilcplex

For installation I needed to add --skip="ThirdParty/HSL ThirdParty/FilterSQP" as neither was available in ThirdParty.

I would like to use Bonmin as a solver within a python script (currently running on windows) via pyomo. When trying to use it, I obtain the error:

[WinError 193] %1 is not a valid Win32 application

Does this imply that I need to install a python version using WSL and start the script from WSL? I'm using pycharm as an IDE and it would be nice to be able to run these scripts from within pycharm. When I used cygwin for building Bonmin (which worked without Cplex) this was actually possible so I'm wondering if I'm interpreting the error correctly.

tkralphs commented 5 years ago

Yes, WSL is really Linux and you cannot mix WSL and Windows for most purposes. Just install pyomo in WSL python and it should work.

CJNeumann commented 5 years ago

Amazing, it finally works! WSL-python can even be added as remote interpreter in pycharm.