Alberto
Alberto

Reputation: 396

Autotools AC_CHECK_LIB get path of library

I am a newbie with Autotools and currently trying to create a configure.ac file in order to check for several dependencies for the later installation of my program.

Now, I want to check the existence of certain libraries and I have found that using AC_CHECK_LIB can do the trick. I think PCK_CHECK_MODULES could help too but I would like to stick to the former unless PCK_CHECK_MODULES solved my problem:

AC_CHECK_LIB does what is expected to do which is to look for the library and perform an action if found or another one if not found, but, my question then is:

If AC_CHECK_LIB finds my library, how can I obtain the exact path of this library? That is to say, if the AC_CHECK_LIB I have is:

AC_CHECK_LIB (foo, function, [action-if-found], [action-if-not-found])

Is there any way for me to get the exact path of this foo library if it is found?

Thanks,

Upvotes: 2

Views: 4103

Answers (1)

John Bollinger
John Bollinger

Reputation: 180048

If AC_CHECK_LIB finds my library, how can I obtain the exact path of this library?

AC_CHECK_LIB does not provide any mechanism by which you could do so. It does not determine an actual location itself. Per its documentation, this is what it actually does:

Test whether the library library is available by trying to link a test program that calls function function with the library. function should be a function provided by the library.

When AC_CHECK_LIB succeeds, then, it knows only that the linker found a library corresponding to the given library name that provides a function having the specified function name. It doesn't know where the linker found it. On the flip side, when that macros does not find a library, that does not necessarily mean it is unavailable, but rather that the linker does not find it subject to the link options, if any, in effect at that point.

Note, too, that that's perfectly satisfactory for many purposes. You need to know the actual location only if you want to use that to locate some other, related resource. And it's rare that configure can find a library without help, yet needs extra information to locate related resources.

Upvotes: 2

Related Questions