[Coin-discuss] How to link my program with Osi

Joe Boublack joe.boublack at gmail.com
Fri Feb 22 08:57:46 EST 2008


2008/2/22, Lou Hafer <lou at cs.sfu.ca>:
> Joe,
>
>         When a Coin project is built, it generates a file, <proj>_addlibs.txt,
>  which contains the list of libraries required by the project. This gets used in
>  Makefile.am files.
>
>         If you look in (for example) Coin-OS/OS/src/Makefile.am, you'll see the
>  technique.
>
>                                                         Lou

Thanks (Lou and other people giving me some hints).

To summarize, Makefile.am files should include such commands for each
library bundled with Osi :

if COIN_HAS_SYMPHONY
 LDADD += $(OSIOBJDIR)/src/OsiSym/libOsiSym.la
 OSSolverService_DEPENDENCIES += $(OSIOBJDIR)/src/OsiSym/libOsiSym.la
endif

However, I'm not convincing this is the better way because :
  1 - new librairies may be added to Osi in the future (to support new
solvers ?)
  2 - I don't know how to compute COIN_HAS_*solver_list* variables in
a portable way (needs for m4 scripts ?)

I feel Coin-Or projects lacks of configure's helper scripts. For
coin-or developpers, I would recommend two possible solutions to help
other people to use their librairies :
 1- make only one "big" librairy (ex: /usr/lib/libcoin-or.so....) to
make this working :
     AC_CHECK_HEADERS(OSInstance.h,
                 COIN_OSI_LIBS="-lcoin-or",
                 COIN_OSI_LIBS=)
  2- Make a configure's helper (ex: /usr/bin/coin-or-config) like in
many other projects providing complex librairies. For example,
$  gtk-config --libs
-L/usr/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm
$ gtk-config --cflags
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
$ xml2-config --libs
-L/usr/lib -lxml2

People could find an example of such scripts here :
http://www.virtualbox.org/browser/trunk/src/libs/libxml2-2.6.30/xml2-config.in

Alternatively, using pkg-config "standard" configure helper
(http://pkg-config.freedesktop.org) :
$ pkg-config glib --libs
-lglib

In a configure.ac, the developer has to add such commands :

dnl Checking for libxml
AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config,
AC_MSG_ERROR(Cannot find xml2-config.))
XML2_LIBS="`$XML2_CONFIG --libs`"
XML2_CFLAGS="`$XML2_CONFIG --cflags`"
AC_SUBST(XML2_LIBS)
AC_SUBST(XML2_CFLAGS)

Hope it helps. I prefer to suspend early linking of Osi with my
software for the moment, I don't want to make my configure build to
much dependent on current Coin-Or files organization.



More information about the Coin-discuss mailing list