4 Replies - 476 Views - Last Post: 17 January 2019 - 03:29 PM

#1 sheshach   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 18
  • Joined: 31-December 18

Autotools nightmare

Posted 14 January 2019 - 07:20 PM

Hey I'm not really sure this is the most appropriate forum. I am trying to use autotools to package this application I have written, and I need to check for libcap (capabilities library, not pcap) and cannot figure out for the life of me why I can't find it. I have managed to search for OpenSSL's libraries with the AC_SEARCH_LIBS directives and so I think I have the syntax correct, it just doesn't seem to find the library (whether it's installed or not ). Maybe I am not even searching for the right library name, but I have managed to at least get it to add "-lcap" to the compiler line by doing...

[AC_CHECK_LIB(cap,[main])


But this doesn't find it...

AC_CHECK_LIB(cap,cap_set_flags, [], [AC_MSG_ERROR([libcap not found])])


Nor this..

AC_SEARCH_LIBS(cap_set_flags,cap libcap, [], [AC_MSG_ERROR([libcap not found])])




One thing I noticed is if I don't check for the library, gcc fails and complains about there not being a sys/capabilities.h file, which is almost as good, if not slightly more cryptic.

I'm wondering from a user-vs-developer perspective which is the best way to do it. Even if I did find the library with autoconf directives on one system, the library could be called something different on another couldn't it?

Meanwhile if a user was trying to compile and saw that some .h file was missing, wouldn't they Google that error, and see that they need to install libcap library files? All autoconf seems to do is cut out the Google step to see what library is missing.

My main thought is that I shouldn't rely on gcc's error message to inform users of the missing library, especially since some other compiler with less informative error messages could be used.

Is This A Good Question/Topic? 0
  • +

Replies To: Autotools nightmare

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6767
  • View blog
  • Posts: 23,071
  • Joined: 05-May 12

Re: Autotools nightmare

Posted 15 January 2019 - 08:53 AM

View Postsheshach, on 14 January 2019 - 09:20 PM, said:

Even if I did find the library with autoconf directives on one system, the library could be called something different on another couldn't it?

You'll need to know the alternative names. See the autoconf documentation for references to other-libraries.
Was This Post Helpful? 0
  • +
  • -

#3 sheshach   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 18
  • Joined: 31-December 18

Re: Autotools nightmare

Posted 17 January 2019 - 01:23 PM

One thing I'm having a heck of a time with is that the library I need is ONE letter off of a very popular library, so when I search Google for "libcap for BSD" I just get results of "libpcap for BSD". It seems there's a port for netBSD, but it's just called libcap as well.

I think I figured out the autotools syntax... I didn't think they made this very clear at all, but what I needed to do was:

AC_CHECK_LIB(cap,[main], [], [AC_MSG_ERROR(libcap not found)])


When it said to specify which function as the 2nd argument, I thought it meant the function that I needed the library for, not which function said library functions were in... Very confusing, but this works.

On Linux that is... It doesn't seem like there is any libcap available other than that NetBSD port.

This post has been edited by Skydiver: 17 January 2019 - 04:01 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6767
  • View blog
  • Posts: 23,071
  • Joined: 05-May 12

Re: Autotools nightmare

Posted 17 January 2019 - 01:52 PM

Huh? The documentation seemed pretty explicit:

Quote

function should be a function provided by the library.

Strange that you had to use [main], instead of cap_set_flags.
Was This Post Helpful? 0
  • +
  • -

#5 sheshach   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 18
  • Joined: 31-December 18

Re: Autotools nightmare

Posted 17 January 2019 - 03:29 PM

Yeah I guess I shouldn't have said it was hard to understand, the behavior just didn't match what was specified.

Maybe it means the functions that the libraries' component functions appear in? In my case, that is definitely in main.

This post has been edited by Skydiver: 17 January 2019 - 04:01 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1