coin-or / coinbrew

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

coinbrew fails (in multiple ways) for CBC on Mac #52

Closed frangio68 closed 3 years ago

frangio68 commented 3 years ago

Hi.

Trying to install CBC on Mac. Even with everything at default, it fails like this:

##################################################
### Building ThirdParty/Metis 1.3.9 
##################################################

/Users/frangio/Applications/CBC/ThirdParty/Metis/metis-4.0/Lib/compress.c:151:3: error: 
      implicit declaration of function '__GKfree' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
  GKfree(&keys, &map, &mark, LTERM);
  ^
/Users/frangio/Applications/CBC/ThirdParty/Metis/metis-4.0/Lib/rename.h:380:19: note: 
      expanded from macro 'GKfree'
#define GKfree                          __GKfree
                                        ^
1 error generated.
make: *** [compress.lo] Error 1

OS is Catalina (10.15.7), no Big Sur yet. Latest clang

clang --version
Apple clang version 12.0.0 (clang-1200.0.32.21)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

It would seem clang has become pickier on C standards, i.e., it is ran by default with

-Werror,-Wimplicit-function-declaration

which crashes things.

I then excluded Metis, which I don't need anyway, and I got

##################################################
### Configuring ThirdParty/Mumps 1.6.2 
##################################################

configure: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: dlfcn.h: proceeding with the compiler's result

...

Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/INTEGER(4)).
/Users/frangio/Applications/CBC/ThirdParty/Mumps/MUMPS/src/dmumps_comm_buffer.F:385:27:

  385 |             CALL MPI_PACK( A( J1 ), LCONT, MPI_DOUBLE_PRECISION,
      |                           1
......
 2658 |         CALL MPI_PACK( WHAT, 1, MPI_INTEGER,
      |                       2    
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/INTEGER(4)).
make: *** [dmumps_comm_buffer.lo] Error 1

Build failed, see error output above

This I could not fathom, and I excluded Mumps as well. However I need OsiCpx, so I need to run

./coinbrew build Cbc --prefix=/Users/frangio/Applications/CBC/ --with-cplex --with-cplex-lib="-L/Users/frangio/Applications/CPLEX_Studio1210/cplex/lib/x86-64_osx/static_pic/ -lcplex -lm" --with-cplex-incdir="/Users/frangio/Applications/CPLEX_Studio1210/cplex/include/ilcplex/" --without-metis --without-mumps

and I got

configure:23357: clang -o conftest -O3 -pipe -DNDEBUG -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas -Wno-long-long   -DOSI_BUILD   conftest.c -L/Users/frangio/Applications/CPLEX_Studio1210/cplex/lib/x86-64_osx/static_pic/ -lcplex -lm  >&5
conftest.c:40:1: error: implicit declaration of function 'CPXgetstat' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
CPXgetstat()
^
....
configure:23386: result: no
configure:23400: error: Cannot find symbol(s) CPXgetstat with CPX

I have checked, and it does not seem my Cplex stuff is out of place. It seems to me this is the same error that Metis gave, hence I suspect it being the same picky compiler issue (-Werror,-Wimplicit-function-declaration).

I have tried to change the setting by adding

--ADD_CFLAGS="--no-warnings"

but then I get

##################################################
### Configuring Data/Sample 1.2.12 
##################################################

configure: error: unrecognized option: --ADD_CFLAGS=--no-warnings
Try `/Users/frangio/Applications/CBC/Data/Sample/configure --help' for more information.

I would happily kill Data (Star Trek fans would hate me ...), but there does not seem a functional way to exclude it in coinbrew.

So, there it is. It may not be a really coinbrew-specific issue, but I guess this is the right place to post it anyway.

Thanks

A.

frangio68 commented 3 years ago

Sorry for the "does not seem a functional way to exclude it in coinbrew", I just noticed the "--skip=Data/Sample" from another post. I got the same error from Data/milplib3, so I have to --skip that as well. It seems that

--skip=Data/Sample --skip=Data/milplib3

does not work, but

--skip="Data/Sample Data/miplib3"

does. In fact this can be avoided, because I was using it wrong: the option is

ADD_CFLAGS="--no-warnings"

With this, finally OSI configuration worked and everything else went smoothly ... almost. The unit test of CBC takes forever, and the process seems to stall forever at

All tests completed successfully ** Unit Test succeeded.

after which I get a weird

make[1]: [test_cbc] Error 1 make: [test] Error 2

Build failed, see error output above

But I needed the OSI stuff and that is done. So, the issue is solved, for me, with

./coinbrew build Cbc ... --without-metis --without-mumps ADD_CFLAGS="--no-warnings"

Hope this is useful to someone. I leave to Ted to close it.

Best

A.

tkralphs commented 3 years ago

Just to summarize, the errors on Metis and OsiCpx are issues with those third-party codes, which have implicit function declarations. clang helpfully offers a remedy, which is to add ADD_CFLAGS=-Werror,-Wimplicit-function-declaration, but the CPLEX error can also be remedied by skipping the library check with --disable-cplex-libcheck.

The Mumps error is probably something to do with having conflicting or incompatible versions of MPI installed, but I guess disabling MPI should fix that (not sure of the configure option for that). For Mumps and Metis, the current master branch will look for pre-installed versions of Metis and Mumps, so it may be easier to install those with homebrew and forget about it.

To make things easy and just skip all the third-party codes, none of which are needed for most use cases, what you probably really want is

coinbrew build Cbc --no-third-party