coin-or / coinbrew

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

Still unable to build a static executable (for debugging by gdb purpose) #46

Closed ebni closed 4 years ago

ebni commented 4 years ago

Dear all,

sorry to bother you with something that seems you solved, but I lost two full days trying all possible permutations with coinbrew/configure/library paths options. I'm having a very hard time to get an stand-alone executable (with statically linked libraries) which just solves your driverC.c example. I was able to use and debug GLPK code very smoothly. A colleague suggested me to switch to your library, which seems more actively supported than GLPK. The hardness to run step by step (by gdb) your libraries is however, becoming a huge obstacle. Any hint or advice?

Best,

Enrico

PS: sorry, if this is the wrong communication channel with you.

tkralphs commented 4 years ago

I guess you're talking about Cbc? coinbrew can be used to build many different packages. Building static libraries for debugging purposes is a different problem than building a fully static executable. To build static libraries for debugging, just add --enable-debug as an argument to coinbrew, as described, e.g., here.

tkralphs commented 4 years ago

Also, to build the examples, build Cbc first, then go into the build/Cbc/<version>/examples directory and do, e.g., make DRIVER=driver. I'm not sure what version you're using exactly.

ebni commented 4 years ago

Thanks for the clarification. I'll try to follow your pointers. Enrico

bradbell commented 4 years ago

I am having similar trouble with coinbrew. It seems that --enable --static does not work when trying to build Ipopt.

For example, if I execute the following commands

./coinbrew fetch Ipopt@3.13.2 --no-prompt
./coinbrew build Ipopt@3.13.2 --enable-debug --static --test --no-prompt --verbosity=3 --prefix=/home/bradbell/prefix/dismod_at --libdir=/home/bradbell/prefix/dismod_at/lib64 ADD_FCFLAGS=-fallow-argument-mismatch

The resulting output is: ... snip ...

configure:3448: error: in `/home/bradbell/repo/dismod_at.git/build/external/build-debug/ThirdParty/ASL/2.0':
configure:3450: error: C compiler cannot create executables
See `config.log' for more details

... snip ...

Looking in build-debug/ThirdParty/ASL/2.0/config.log I see the same text as above. Here is the configure command at the beginning of that file:

  $ /home/bradbell/repo/dismod_at.git/build/external/ThirdParty/ASL/configure --disable-dependency-tracking --prefix=/home/bradbell/prefix/dismod_at ADD_FCFLAGS=-fallow-argument-mismatch LDFLAGS=-static --enable-debug --libdir=/home/bradbell/prefix/dismod_at/lib64 --disable-shared --with-coin-instdir=/home/bradbell/prefix/dismod_at LT_LDFLAGS=-all-static

If I remove the --enable-debug --static from the coinbrew command line I do not get the error. Here is the corresponding configure command from build/ThirdParty/ASL/2.0/config.log

 $ /home/bradbell/repo/dismod_at.git/build/external/ThirdParty/ASL/configure --disable-dependency-tracking --disable-option-checking --prefix=/home/bradbell/prefix/dismod_at ADD_FCFLAGS=-fallow-argument-mismatch --libdir=/home/bradbell/prefix/dismod_at/lib64 --with-coin-instdir=/home/bradbell/prefix/dismod_at
tkralphs commented 4 years ago

This report isn't really related to the original bug report, which has to do with static executables, not static libraries. But in any case, with Ipopt master, you just need --enable-debug and --disable-shared, not --static. The --static flag is a coinbrew flag, not a configure flag and it's to add flags needed for building static executables, which is a whole different thing. I guess the problem you're running into is that the --static flag is causing some configure options to be added that don't work with Ipopt for some reason. If I do

coinbrew build Ipopt --enable-debug --disable-shared

everything goes through fine and I get static libraries.

bradbell commented 4 years ago

Works for me. Thanks.