coin-or / coinbrew

COIN-OR build and installation script
29 stars 15 forks source link

build fails under Windows #87

Closed dmeoli closed 1 year ago

dmeoli commented 1 year ago

Hi.

I am trying to install Coinbrew as follows:

bash coinbrew build Cbc --prefix=C:\CBC --with-cplex --with-cplex-lib="-LC:/Program Files/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda -lcplex12100 -lm" --with-cplex-incdir="C:/Program Files/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex" --with-gurobi --with-gurobi-lib="-LC:/gurobi1002/win64/lib -lgurobi100" --with-gurobi-incdir="C:/gurobi1002/win64/include" --without-metis --without-mumps --without-cholmod --without-lapack --without-asl --without-glpk --without-hsl --without-blas ADD_CFLAGS="--no-warnings" --tests=none --enable-msvc --build=x86_64-w64-mingw32

but I obtain the following error:

ifdef __cplusplus

extern "C" void std::exit (int) throw (); using std::exit;

configure: exit 1

the complete log here.

Moreover, the log also reports:

configure: WARNING: Failed to find a Fortran compiler!

although Fortran is linked in the path:

C:> gfortran --version GNU Fortran (MinGW.org GCC-6.3.0-1) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc.

Any help would be appreciated, I need OSI working under Windows.

THX Y'ALL

svigerske commented 1 year ago

The relevant error message is

/mnt/c/Osi/Osi/configure: line 23272: cd: too many arguments
configure: error: Cannot find file cplex.h in /mnt/c/build/Osi/0.108

The space in the path to CPLEX is probably the issue, and responsible for the "cd: too many arguments" and the confusing "in /mnt/c/build/Osi/0.108".

Try coping CPLEX headers and libs into some other directory without a space in the path.

And if you want Osi, then build just Osi, not Cbc.

dmeoli commented 1 year ago

OK, thx @svigerske , now the CPLEX path is spaceless, but I obtained the same error, log here.

In particular: [ . . . ] /mnt/c/Osi/Osi/configure: line 23272: cd: C:/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex: No such file or directory configure: error: Cannot find file cplex.h in /mnt/c/build/Osi/0.108 [ . . . ]

but:

C:\IBM\ILOG\CPLEX_Studio1210\cplex\include\ilcplex> ls

-a---- 26/06/2023 18:02 2505 annotation.xsd -a---- 26/06/2023 18:02 81816 cplex.h -a---- 26/06/2023 18:02 6430 cplexcheck.h -a---- 26/06/2023 18:02 1704 cplexdistmip.h -a---- 26/06/2023 18:02 1858 cplexdistmipl.h -a---- 26/06/2023 18:02 1858 cplexdistmips.h -a---- 26/06/2023 18:02 2570 cplexdistmipx.h -a---- 26/06/2023 18:02 87058 cplexl.h -a---- 26/06/2023 18:02 1729 cplexremote.h -a---- 26/06/2023 18:02 1847 cplexremotel.h -a---- 26/06/2023 18:02 23240 cplexremotemaster.h -a---- 26/06/2023 18:02 24692 cplexremotemasterl.h -a---- 26/06/2023 18:02 24677 cplexremotemasters.h -a---- 26/06/2023 18:02 47199 cplexremotemasterx.h -a---- 26/06/2023 18:02 1847 cplexremotes.h -a---- 26/06/2023 18:02 2282 cplexremoteworker.h -a---- 26/06/2023 18:02 2408 cplexremoteworkerl.h -a---- 26/06/2023 18:02 2414 cplexremoteworkers.h -a---- 26/06/2023 18:02 3457 cplexremoteworkerx.h -a---- 26/06/2023 18:02 2192 cplexremotex.h -a---- 26/06/2023 18:02 86741 cplexs.h -a---- 26/06/2023 18:02 135572 cplexx.h -a---- 26/06/2023 18:02 74003 cpxconst.h -a---- 26/06/2023 18:02 676 ilm.h -a---- 26/06/2023 18:02 7159 ilocarray.h -a---- 26/06/2023 18:02 183443 ilocplex.h -a---- 26/06/2023 18:02 220856 ilocplexi.h -a---- 26/06/2023 18:02 1124 iloCPXCALLBACKINFOenum.h -a---- 26/06/2023 18:02 785 iloCPXCALLBACKSOLUTIONSTRATEGYenum.h -a---- 26/06/2023 18:02 13175 iloextrmgr.h -a---- 26/06/2023 18:02 13497 ilogoals.h -a---- 26/06/2023 18:02 3228 ilomodelasst.h -a---- 26/06/2023 18:02 16217 iloparam.h -a---- 26/06/2023 18:02 5705 solution.xsd -a---- 26/06/2023 18:02 5504 solution.xsl -a---- 26/06/2023 18:02 1397 vmc.dtd -a---- 26/06/2023 18:02 2837 vmc.xsd

tkralphs commented 1 year ago

All your paths are posix except for that one, which is Windows. It is configure (a bash script) that is complaining, so I would assume it's not automatically converting the path. If I recall correctly, some conversion does happen automatically with the MinGW tool chain, but probably not in this context. IN any case, all of the tools you're using certainly do understand posix paths, so try using the path \mnt\c\IBM\ILOG\CPLEX_Studio1210\cplex\include\ilcplex. It's still a good thing not to have spaces in the path.

dmeoli commented 1 year ago

OK, now with:

bash coinbrew build Cbc --with-cplex --with-cplex-lib="-L/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda -lcplex12100 -lm -ldl" --with-cplex-incdir="/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex" --with-gurobi --with-gurobi-lib="-L/mnt/c/gurobi1002/win64/lib -lgurobi100" --with-gurobi-incdir="/mnt/c/gurobi1002/win64/include" --without-metis --without-mumps --without-cholmod --without-lapack --without-asl --without-glpk --without-hsl --without-blas ADD_CFLAGS="--no-warnings" --tests=none --enable-msvc --build=x86_64-w64-mingw32

I obtain this.

I think that the root of the problem is:

configure: error: Cannot find symbol(s) CPXgetstat with CPX

despite the -ldl flag for the option --with-cplex-lib.

tkralphs commented 1 year ago

It seems you are trying to build with the Microsoft Visual Studio compiler, since you are adding --enable-msvc as an argument to configure and this has the effect of prioritizing the Visual Studio compiler. However, the Visual Studio compiler has not been found (see lines 213 and 225 of your output), so configure had found instead the MinGW gcc compiler (see lines 214 and 226). But meanwhile, you are trying to link with a library that is built with the Visual Studio compiler. This is not going to work. You need to follow the detailed instructions for building with the Visual Studio compiler from MSys are here. If you have questions, feel free to follow up.

svigerske commented 1 year ago

The config.log also says why it couldn't find CPXgetstat:

configure:23366: gcc -o conftest -O3 -pipe -DNDEBUG -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas -Wno-long-long --no-warnings  -DOSI_BUILD   conftest.c -L/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda -lcplex12100 -lm -ldl  >&5
/usr/bin/ld: cannot find -lcplex12100: No such file or directory

The -lcplex12100 would look for libcplex12100.lib, but you probably have cplex12100.lib.

Using --with-cplex-lib=/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib may work better.

dmeoli commented 1 year ago

OK, let's suppose that for simplicity I decided to use MSYs2. after removing MinGW and installing MSYs2, and then after running the commands in the guide here, I run:

bash coinbrew build Cbc --with-cplex --with-cplex-lib="-L/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib -lm -ldl -lpthread" --with-cplex-incdir="/mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex" --with-gurobi --with-gurobi-lib="-L/mnt/c/gurobi1002/win64/lib -lgurobi100" --with-gurobi-incdir="/mnt/c/gurobi1002/win64/include" --without-metis --without-mumps --without-cholmod --without-lapack --without-asl --without-glpk --without-hsl --without-blas ADD_CFLAGS="--no-warnings" --tests=none --build=x86_64-w64-mingw32

and I obtain this.

svigerske commented 1 year ago

--with-cplex-lib without -L.

dmeoli commented 1 year ago

Nothing changed

Log here.

tkralphs commented 1 year ago

I'm a little unclear as to exactly what you are (and were) doing, as well as what you're trying to achieve. I had assumed you were already using MSys2, since you had a bash command available from somewhere in your first build environment. But you said you only now installed MSys2 and uninstalled MinGW, so maybe that was WSL? In the second build, you dropped the --enable-msvc, I guess intentionally, and configure still finds a gcc installation on your system. If you uninstalled MinGW, I don't know where that is coming from.

In any case, it seems you are still trying to use gcc to link to a library built with Visual Studio 14, so I think the issue is still the same as before. The linker now finds the library, but it looks to be incompatible. Here is the error message from config.log:

/usr/bin/ld: /mnt/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib(cplex12100.dll): recognised but unhandled machine type (0x8664) in Import Library Format archive

As I said, I don't think this is going to work---the easiest route is to use the Visual Studio compiler to build your application. Install Visual Studio and then follow the directions here, not here.

If you can explain what end result you are looking for, I could provide more help. Osi is only going to be useful if you link it into a larger application and the way you plan to build that application (what toolchain, etc.) will dictate how you need to build Osi.

dmeoli commented 1 year ago

@tkralphs I had previously installed minGW with this installer, then I removed it and I installed MSys2.

I followed the guide here but at the moment it is stuck in the Data/Sample building and doesn't seem to want to make any further progress.

Log here.

tkralphs commented 1 year ago

OK, so I now realized that you were in fact using WSL to start with because in WSL, the C: drive is mounted as /mnt/c/, whereas in MSys2, it is mounted as /c. If you were using WSL to start with, then it is very likely that the version of gcc you were actually using was the Linux version that would have come with WSL (WSL is essentially Linux running in a VM within Windows), not the gcc from MinGW. When switching to MSys2, you are probably using the MinGW version of gcc (although you said you uninstalled it). Everything else aside, when you are building in MSys2, your posix paths should all start with /c rather than the /mnt/c/ you used in WSL.

I just executed the exact command you did in my own MSys2 environment and had no problems. So unfortunately, I don't have a guess as to what's going on now. I'm not surprised there are problems with the build, given the error that was output during configuration. That error occurs on this line in the configure script.

eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`

So something weird is going on with your make command. Maybe you didn't install everything you were supposed to? You need the package for the MinGW toolchain even if you are using the MinGW compiler.

If you want to post the full output from running coinbrew again with --verbosity=4, I'll see if I can guide you further, but you still haven't said what you're trying to accomplish exactly and this is taking more time than I have to devote to it right now.

svigerske commented 1 year ago

This make call in configure is supposed to print ac_maketemp="$(MAKE)", so one would need to run ${MAKE-make} -f conftest.make in /c/build/Data/Sample (provided that conftest.make is still there) and see what that returns.

Again, if one wants to build Osi, then I don't see why one would attempt to build all of Cbc here. Building just CoinUtils and Osi should be sufficient (or telling coinbrew to build Osi should be sufficient).

Also, if things moved from WSL to Msys2 now, then paths like /mnt/c should become /c in the configure flags, I suppose.

dmeoli commented 1 year ago

Here the log of the previous command with --verbose=4 and also the path fixed as /c and not /mnt/c.

I need Clp, Osi and CoinUtils. I installed coin-or-osi, coin-or-clp, and coinutils under Windows with vcpkg, but obv OsiGrbInterface.hpp and OsiCpxInterface.hpp are missing. Assuming that I can use the coin-or-clp and coinutils installed via vcpkg and build only Osi (?), I run:

bash coinbrew build Osi . . .

but I obtain the same error.

The problem I think is:

/c/Data/Netlib/missing: line 52: automake-1.9: command not found

but the specific v1.9 is not available on the repo.

svigerske commented 1 year ago

It is not the same error. It is yet a different one.

It shouldn't usually try to run automake, so you won't need to install it. Maybe the last time you interrupted it after line 1680: unexpected EOF while looking for matching ", because in https://pastebin.com/VHqHnL8u the log ended there suddenly? This time it seems to actually continue. But if there was some half-finished configure run in that directory, it may got confused. In any case, always remove /c/build before starting coinbrew.

If you have CoinUtils, you can try to build Osi only, using the usual configure/make/make install steps for Osi, but specifying some configure flags on how to find your CoinUtils installation. Maybe its not yet the time to go this way.

dmeoli commented 1 year ago

@svigerske I always remove the build folder among different buildings obv :-)

I stopped the execution of the run https://pastebin.com/VHqHnL8u since it wasn't making progress after 1 or 2 hours. In fact, when I added the option --verbose=4 as suggested by @tkralphs I clearly noticed a loop, in particular the snippet:

[. . .] cd /c/Data/Sample && C:/msys64/usr/bin/sh.exe /c/Data/Sample/missing --run automake-1.9 --foreign Makefile /c/Data/Sample/missing: line 52: automake-1.9: command not found WARNING: automake-1.9' is missing on your system. You should only need it if you modifiedMakefile.am', acinclude.m4' orconfigure.ac'. You might want to install the Automake' andPerl' packages. Grab them from any GNU archive site. cd /c/Data/Sample && C:/msys64/usr/bin/sh.exe /c/Data/Sample/missing --run autoconf /c/Data/Sample/missing: line 52: autoconf: command not found WARNING: autoconf' is missing on your system. You should only need it if you modifiedconfigure.ac'. You might want to install the Autoconf' andGNU m4' packages. Grab them from any GNU archive site. C:/msys64/usr/bin/sh.exe ./config.status --recheck running /bin/sh /c/Data/Sample/configure --disable-dependency-tracking --prefix=/c/dist --with-gurobi-lib=-L/c/gurobi1002/win64/lib -lgurobi100 --without-hsl --with-cplex --build=x86_64-w64-mingw32 --with-coin-instdir=/c/dist --with-cplex-incdir=/c/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex --without-cholmod --with-gurobi --enable-msvc --without-glpk --without-blas --with-cplex-lib=/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib -lm -ldl -lpthread --without-asl --with-gurobi-incdir=/c/gurobi1002/win64/include --without-mumps --without-metis ADD_CFLAGS=--no-warnings --without-lapack build_alias=x86_64-w64-mingw32 --no-create --no-recursion checking for svnversion... no checking for egrep... grep -E checking whether ln -s works... yes checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... /c/Data/Sample/configure: eval: line 1680: unexpected EOF while looking for matching `"' no checking whether to enable maintainer-specific portions of Makefiles... no checking whether this is a VPATH configuration... yes checking build system type... x86_64-w64-mingw32 configure: Copying example files (.mps) configure: Copying example files (.lp) configure: Copying example files (.block) configure: Copying example files (.dec) configure: Copying example files (input.130) configure: Copying example files (app0110. app0110R. bug.*) checking which command should be used to link input files... ln -s configure: creating ./config.status configure: In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting configure: Configuration of DataSample successful C:/msys64/usr/bin/sh.exe ./config.status config.status: creating Makefile config.status: creating coindatasample.pc config.status: creating coindatasample-uninstalled.pc [. . .]

is repeated over and over again and never ends, and the same thing happened when I tried to build Osi only.

tkralphs commented 1 year ago

It's a bit weird that configure could go into an infinite loop because of missing commands. But these two warnings indicate that the reason for your problems might be that configure.ac or Makefile.am were somehow modified.

WARNING: automake-1.9' is missing on your system.  You should only need it if you modified Makefile.am', acinclude.m4' or configure.ac'.
WARNING: autoconf' is missing on your system.  You should only need it if you modified configure.ac'. 

Obviously, these should not ordinarily be modified, but it would be easy to check if they were somehow modified by just doing a git status in Data/Sample. This is the very first time I've heard of any issue like this from any user. My only educated guess is that you have the git settings related to line endings set such that when you check out the files on WIndows, the line endings are changed. If so, the files may appear to be modified, even though they are now. But I find it hard to believe, if this is the issue, that you are the only person ever to have run into this. You should read this or any number of other documents you can find explaining the issues around line endings in git. It's a tricky issue and has tripped me up before.

svigerske commented 1 year ago

It shouldn't even try to regenerate Makefile.in if Makefile.am is modified, because maintainer mode is off.

 checking whether to enable maintainer-specific portions of Makefiles... no

I would think Makefile.in is only attempted to be generated if it doesn't exist for some reason, or the am--refresh target is called, for some other reason. Best would be to just investigate/debug on the machine what is happening.

dmeoli commented 1 year ago

Tbh, I do not know exactly what happens, but after installing autotools with:

pacman -S "${MINGW_PACKAGE_PREFIX}-autotools"

as suggested by the guide here, and also:

pacman -S --noconfirm git wget tar gzip autoconf automake make libtool patch unzip xz bison flex pkg-config

as suggested here (I think that pkg-config makes the difference), everything seems to work well with the command:

bash coinbrew build Osi --with-cplex --with-cplex-lib="/c/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib -lm -ldl -lpthread" --with-cplex-incdir="/c/IBM/ILOG/CPLEX_Studio1210/cplex/include/ilcplex" --with-gurobi --with-gurobi-lib="/c/gurobi1002/win64/lib/gurobi100.lib" --with-gurobi-incdir="/c/gurobi1002/win64/include" --without-metis --without-mumps --without-cholmod --without-lapack --without-asl --without-glpk --without-hsl --without-blas ADD_CFLAGS="--no-warnings" --tests=none --enable-msvc --build=x86_64-w64-mingw32

@tkralphs probably you should update the guide to install on Windows with MSys2..

Thx for your help, guys! :-)

dmeoli commented 1 year ago

How can I also install Clp with the OsiClpSolverInterface.hpp without passing from Cbc?

tkralphs commented 1 year ago

@tkralphs probably you should update the guide to install on Windows with MSys2. Update how? The guide already says in the section on setting up coinbrew to install the necessary packages as follows.

pacman -S make wget tar patch dos2unix diffutils git svn pkg-config zip unzip

The others in the guide you pointed to are not needed (and in particular, I'm sure the autotools are not needed---you are the first person I'm aware of who ran into this particular problem and it was probably the result of other factors).

Aside from the documentation, the coinbrew output also contains this strong warning.

No pkg-config or pkgconf found on system
If packages are not found during configuration,
this could be the reason. Installation is highly recommended.
See https://coin-or.github.io for details

As far as I can tell (although there is still some uncertainty about what really happened), the guide is correct and if followed to the letter, will result in success.

How can I also install Clp with the OsiClpSolverInterface.hpp without passing from Cbc? I'm not sure what you mean by "without passing from Cbc," but OsiClp is built automatically when Clp is built, as long as Osi is already installed. coinbrew ensures that they are built in the right order for this to happen. So if you just simply build Clp, you will get OsiClp automatically.