Force linking a static library into a shared one with Libtool

前端 未结 2 1744
礼貌的吻别
礼貌的吻别 2021-02-20 02:15

I have a library (libfoo) that is compiled using libtool into two objects: libfoo.a and libfoo.so.

I have to create, using libtool

相关标签:
2条回答
  • 2021-02-20 02:25

    The standard way would be to build libfoo with --disable-shared. Whether to link statically or dynamically is a decision for the user to make, so there's really no way to force it as a package maintainer, but you could set the configury of libbar to fail if libfoo.so is present (I'm not sure of a clean way to do that, and believe it would be a bad idea since it really is a choice for the user.) I think the best bet is to have the user build libfoo with --disable-shared, but you can force that choice by specifying static libraries only in libfoo/configure.ac:

    LT_INIT([disable-shared])
    

    Note that if you do that, it will not be possible to build libfoo as a shared library. Perhaps that is what you want.

    0 讨论(0)
  • 2021-02-20 02:49

    You could probably use a convenience library. Convenience libraries are intermediate static libraries which are not installed. You could use the prefix noinst to build one.

    noinst_LTLIBRARIES = libfoo_impl.la
    
    lib_LTLIBRARIES = libfoo.la libbar.la
    libfoo_la_LIBADD = libfoo_impl.la
    libbar_la_LIBADD = libfoo_impl.la
    
    0 讨论(0)
提交回复
热议问题