[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding library procedures in /usr/local/lib/

From: John Calcote
Subject: Re: Finding library procedures in /usr/local/lib/
Date: Fri, 03 Apr 2009 12:46:19 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2

On 4/3/2009 12:29 PM, Ralf Wildenhues wrote:
Hello Gerald,

* Gerald I. Evenden wrote on Fri, Apr 03, 2009 at 08:11:22PM CEST:
One added note, that bothers me a little.

If the system checks for an entry being present in a particular iibrary by
compiling/linking a test program using the function *and* linking to the
specified library,---->  what if the library under test heavily references
another library such as -lm??  IF -lm is not in the test run would the test
not fail???????  Thus the entry under test fails also.

I haven't read the thread in full, but this is probably the issue
bothering you:

AC_CHECK_LIB and AC_SEARCH_LIBS both have an optional 5th argument where
one can supply additional needed libraries.  So of libfoo needs libm,
then a check for libfoo could look like

   AC_SEARCH_LIBS([function_from_libfoo], [foo], [], [], [-lm])
I sure don't know what's happening to my email messages lately. This is the third time this month that some response of mine has apparently been completely lost by Google mail. I sent this response to this thread last night (via Mozilla Thunderbird client), which goes hand-in-hand with Ralf's response above, but provides more details:

- - - - - -

I presume that the reason you link with both libproject and the math library is because libproject requires libm. This could explain why your tests are failing to "find" libproject. Try adding this test to


Tests in "look" for libraries by actually building programs that attempt to link the specified symbol from the specified list of libraries. If the program links, then the test succeeds. The default action in successful cases for AC_SEARCH_LIBS is to add "-lprojects" to the LIBS variable, which is automatically added to your compiler command line (at least by Automake-generated makefiles). If the library that AC_SEARCH_LIBS attempts to link to requires other non-default libraries (like libm, for instance), then you have to add this list of linker commands to the "other-libraries" argument, or the test will fail, even if the function is found in the desired library.

The documentation for AC_SEARCH_LIBS indicates that, on successfully testing for the desired library, this macro prepends -lproject to LIBS, and then executes the shell code in the "action-if-found" parameter, thus, you don't need to add -lproject to LIBS, because this is done by the macro before any additional shell code you specify is executed.

You can also use the following macro, which generates shell code that is a little less complex. But it's a bit harder to use correctly, as you have to write the entire "action-if-found" functionality yourself. The carriage returns are fairly important here:

[LIBS=-lproject $LIBS

AC_CHECK_LIB has no success functionality that executes even if you supply the "action-if-found" argument. All of it's success functionality is given by the default value of the argument. Thus, if you supply the argument, you have to supply all of the appropriate functionality for a successful check. In this case, the macro is supposed to prepend -lproject to LIBS, and then define HAVE_LIBPROJECT.

You might also check the config.log file for failed tests that you believe should work. Each failed test is listed in full in config.log, along with the output of the compiler and linker, so you can probably easily see why the test failed.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]