Howto add a link to a library in autoconf configure script / makefile

前端 未结 2 1214
庸人自扰
庸人自扰 2021-02-07 06:57

I am an autotools newb and I have difficulties figuring out howto easily link a specific library into one of the configured targets.

I have a source package that I want

2条回答
  •  孤独总比滥情好
    2021-02-07 07:32

    Use ax_cxx_check_lib.m4 because boost_system does not have any extern "C" symbols (unmangled names) that can be checked with AC_CHECK_LIB:

    http://ac-archive.sourceforge.net/guidod/ax_cxx_check_lib.m4

    Download the file above and name it acinclude.m4, and put it in the m4 folder in your project root.

    In configure.ac:

    AC_LANG_PUSH([C++])
    
    AX_CXX_CHECK_LIB([boost_system-mt],[boost::system::generic_category()],[BOOST_LIB_SUFFIX="-mt"],[BOOST_LIB_SUFFIX=""])
    
    AC_LANG_POP([C++])
    
    AC_SUBST(BOOST_LIB_SUFFIX)
    

    In Makefile.am:

    [artifact_name]_LDFLAGS = -lboost_system@BOOST_LIB_SUFFIX@
    

提交回复
热议问题