Ticket #648 (new defect)

Opened 3 years ago

Last modified 18 months ago

Cabal C lib check error message is occasionally misleading

Reported by: GregoryWeber Owned by:
Priority: normal Milestone:
Component: Cabal library Version: 1.6.0.1
Severity: normal Keywords:
Cc: Difficulty: unknown
GHC Version: Platform: Linux

Description

This problem occurs with Cabal version 1.8.0.2 on Arch Linux (this version number does not appear in the Version selector, so I have left it at 1.6.0.1) and ghc version 6.12.1.

Trying to install Codec-Image-DevIL, either version 0.1 or 0.2.0, 'runghc Setup configure' produces a misleading error message:

$ runghc Setup configure

Configuring Codec-Image-DevIL-0.2.0... Setup: Missing dependency on a foreign library: * Missing C library: IL This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is.

The error message "Missing C library: IL" is incorrect: the Arch 'devil' package is installed, and the include and library files are present in the normal locations:

$ pacman -Q devil

devil 1.7.8-6

$ ls /usr/include/IL

devil_cpp_wrapper.hpp il.h ilu.h ilu_region.h ilut.h

$ ls /usr/lib/*IL*

/usr/lib/libIL.a /usr/lib/libILU.a /usr/lib/libILUT.a /usr/lib/libIL.so@ /usr/lib/libILU.so@ /usr/lib/libILUT.so@ /usr/lib/libIL.so.1@ /usr/lib/libILU.so.1@ /usr/lib/libILUT.so.1@ /usr/lib/libIL.so.1.1.0* /usr/lib/libILU.so.1.1.0* /usr/lib/libILUT.so.1.1.0*

There does seem to be an error in Codec-Image-DevIL.cabal: where it says

Extra-Libraries: IL

it should say any of the following (take your choice, all of them work):

Extra-Libraries: IL, pthread

Extra-Libraries: IL, rt

Extra-Libraries: IL, pthread, rt

It seems that using the IL library in a C program requires linking with -lrt or -pthread in addition to -lIL.

I have the impression that in the configuration step, when Cabal sees the line

Extra-Libraries: IL

it writes a small C program that tries to include that library, and reports the library is missing if there's an error in compiling and linking the C program. Maybe Cabal needs to interpret the C compiler's and linker's error messages more carefully.

Change History

in reply to: ↑ description   Changed 3 years ago by duncan

Replying to GregoryWeber:

I have the impression that in the configuration step, when Cabal sees the line Extra-Libraries: IL it writes a small C program that tries to include that library, and reports the library is missing if there's an error in compiling and linking the C program. Maybe Cabal needs to interpret the C compiler's and linker's error messages more carefully.

This is correct. We cannot in general interpret the C compilers error messages. They are too varied. We should consult what autoconf does here. It takes the same strategy and does not try to interpret error messages. Perhaps we can just improve the message, to make clear it's only the mostly likely reason, not an absolute conclusion. We should also save the log for users to inspect if they choose. This should make it easier to see what is really going on.

See also #532 for other instances of this problem.

As you say, although the error message is wrong here, the problem is real. The package does depend on pthread or rt but does not say so.

  Changed 3 years ago by GregoryWeber

Thank you. Recognizing that interpreting C compilers' error messages would be too difficult, I agree that saying it's (only) the "most likely" reason, and making the log available, would be helpful.

I also agree that the package needs to state the dependency in Codec-Image-DevIL.cabal, and I have notified the maintainere of the package.

  Changed 3 years ago by kmcallister

  • owner set to kmcallister
  • status changed from new to assigned

  Changed 3 years ago by kmcallister

Patch is attached to #532.

  Changed 3 years ago by duncan

  • owner kmcallister deleted
  • status changed from assigned to new

The more common problem reported in #532 is now fixed. The specific instance of the problem here is with libraries. The linking failing usually but not always means the library is missing. As in this case it can be that dependent C libs (eg pthread) have not been listed.

The error message for the linking failing case should be adjusted similarly to the header check to indicate it may be bad, and to re-run with -v3 for the full linker error.

  Changed 3 years ago by duncan

  • summary changed from Cabal incorrectly reports missing C library IL to Cabal C lib check error message is occasionally misleading

  Changed 18 months ago by elga

Note: See TracTickets for help on using tickets.