question about AC_CHECK_LIB
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > question about AC_CHECK_LIB




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    question about AC_CHECK_LIB  
gelbeiche


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-14-06 03:40 AM

I write a m4 macro and in this macro I try to detect
a library with AC_CHECK_LIB.
AC_CHECK_LIB($ax_lib, main, ...)
where ax_lib is my library.
The check fails because the generated code does not link
against the library.
I catched the generated code from the configure script,
tried to compile it and the linker reveals the reason:

/usr/local/lib/libboost_unit_test_framework.so: undefined reference to `init
_unit_test_suite(int, char**)'
collect2: ld returned 1 exit status

libboost_unit_test_framework.so is my lib ($ax_lib) and this lib
requires some other code.

How is it possible to check the library ?

I have only the idea to look if the library axist as file in my lib-director
y.
But is there a better solution ?





[ Post a follow-up to this message ]



    Re: question about AC_CHECK_LIB  
Roger Leigh


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-14-06 03:40 AM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

gelbeiche <borstel@fliegenpilz.de> writes:

> I write a m4 macro and in this macro I try to detect
> a library with AC_CHECK_LIB.
> AC_CHECK_LIB($ax_lib, main, ...)
> where ax_lib is my library.
> The check fails because the generated code does not link
> against the library.

If you are using a C++ library, as the post implies, try something
along these lines to check if it's possible to instantiate a class
from the library:

saved_ldflags="${LDFLAGS}"
LDFLAGS="${LDFLAGS} -lboost_program_options"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <boost/program_options.hpp
>],
& #91;boost::program_options::variables_ma
p::variables_map dummy()])],
[AC_MSG_RESULT([yes])
BOOST_LIBS="-lboost_program_options"],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([libboost_program_options (Boost C++ Libraries) is not in
stalled, but is required by $PACKAGE])])
LDFLAGS="${saved_ldflags}"
AC_SUBST([BOOST_LIBS])

If you are doing it properly, you'd also replace the '#' with a
quadrigraph, though in this case it doesn't appear to be strictly
required.  If you are mixing languages, you also want to wrap that
with AC_LANG_PUSH and AC_LANG_POP to make sure it uses the C++
variants of those macros.


Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
Debian GNU/Linux        http://www.debian.org/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFDxZPgVcFcaSW/uEgRAtDZAJ4u5FsA5RpZE7To4/ZUc4b1plU9dACeJ5uI
MiXY4B3Pz2TfeDv6uhwbYIU=
=4qHH
-----END PGP SIGNATURE-----





[ Post a follow-up to this message ]



    Re: question about AC_CHECK_LIB  
gelbeiche


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-14-06 03:41 AM

Roger Leigh <${rleigh}@invalid.whinlatter.ukfsn.org.invalid> writes:

> gelbeiche <borstel@fliegenpilz.de> writes:
> 
>
> If you are using a C++ library, as the post implies, try something
> along these lines to check if it's possible to instantiate a class
> from the library:
>
> saved_ldflags="${LDFLAGS}"
> LDFLAGS="${LDFLAGS} -lboost_program_options"
> AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <boost/program_options.h
pp>],
>                                & #91;boost::program_options::variables_ma
p:
:variables_map dummy()])],
>                [AC_MSG_RESULT([yes])
> 	        BOOST_LIBS="-lboost_program_options"],
>                [AC_MSG_RESULT([no])
> 	        AC_MSG_FAILURE([libboost_program_options (Boost C++ Libraries
) is not installed, but is required by $PACKAGE])])
> LDFLAGS="${saved_ldflags}"
> AC_SUBST([BOOST_LIBS])
>
> If you are doing it properly, you'd also replace the '#' with a
> quadrigraph, though in this case it doesn't appear to be strictly
> required.  If you are mixing languages, you also want to wrap that
> with AC_LANG_PUSH and AC_LANG_POP to make sure it uses the C++
> variants of those macros.
>

Good hint ! This is the way I go now.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:31 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register