Autoconf — including a static library (newbie)

前端 未结 1 1672
太阳男子
太阳男子 2021-02-05 13:11

I am trying to migrate my application from manual build to autoconf, which is working very nicely so far. But I have one static library that I can\'t figure out how to integrat

相关标签:
1条回答
  • 2021-02-05 14:08

    You can set the location in configure.ac:

    LOCATION=/home/john/mystuff
    AC_SUBST(LOCATION)
    

    AC_SUBST defines the variable $LOCATION in all your Makefile.ams and also replaces all occurrences of @LOCATION@ with the contents of $LOCATION. So then in your Makefile.am you can do

    myprog_CPPFLAGS="-I$LOCATION"
    myprog_LDADD="$LOCATION/helper.a"
    

    PS. The reason why you need to reference the library directly is because -l looks for a properly-named library (e.g. libhelper.a) in the system library directories. However, since there's not all that much difference between a static library and an object file, there's no need to magically reference it using -l; you can just compile it into your program like you are doing now.

    0 讨论(0)
提交回复
热议问题