[Hackage] #262: Check for required C libraries during configure

Hackage trac at galois.com
Thu Jan 22 12:53:23 EST 2009

#262: Check for required C libraries during configure
  Reporter:  guest          |        Owner:                 
      Type:  enhancement    |       Status:  new            
  Priority:  high           |    Milestone:  Cabal-1.6      
 Component:  Cabal library  |      Version:        
  Severity:  normal         |   Resolution:                 
  Keywords:                 |   Difficulty:  easy (<4 hours)
Ghcversion:  6.8.2          |     Platform:                 
Comment (by duncan):

 Replying to [comment:9 alexeevg]:
 > Autoconf uses AC_CHECK_LIB macro to check if the library is present.
 AC_CHECK_LIB takes the library name and a function(symbol) name that is
 expected to be exported from the library, generates a C program depending
 on this symbol and tries compiling it. This is a bit of info we miss in
 BuildInfo - we have extra-libs, but no function names.

 Right, we do not have this additional information. As you say, we will
 have to rely on `ld` being paranoid and failing when it cannot find a
 library, even if the object files do not depend on any function exported
 by that library.

 Actually, I think ld pretty much has to have this behavior since it does
 not know what symbols the missing library might export that would shadow
 symbols exported by other libraries. So it cannot actually determine if
 the library is not needed, at least for ELF linkers.

 > > Error messages should be helpful for the typical Cabal user, who
 should not be assumed to know > anything about C libraries or linking.
 > This is a bit unclear to me - we have no info on required packages, we
 have only includes/extra-libs, how do we make error messages user-
 friendly? Autoconf doesn't do it.

 You're right that we cannot easily or accurately map missing C libs back
 to which native OS packages that provide them. I think we can still
 produce reasonable error messages. We can at least explain which C
 libraries are missing, we must make it clear that these are C libraries
 (not Haskell packages) that we expected to find on the system. Then there
 are two possible causes with corresponding solutions:

  * The most likely is that the C package is just not installed, or that
 the development flavour of the package is not installed (binary Linux
 distros often split packages into runtime and dev variants). We can
 recommend users look for a native package with a similar name to the C
 lib, and if there is a "-dev" version then install that. We could provide
 more detail and say the native package should provide a file `libfoo.so`
 or `libfoo.a` or whatever.

  * Another possibility is that the C lib is installed but in some non-
 standard location. In that case we should tell users about the `--extra-
 include-dirs` and/or `--extra-lib-dirs` flags.

 Just for my own future reference:
   * [http://www.gnu.org/software/hello/manual/autoconf/Libraries.html
   * [http://www.gnu.org/software/hello/manual/autoconf/Generic-
 Headers.html AC_CHECK_HEADER]

Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/262#comment:11>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects

More information about the cabal-devel mailing list