Force linking a static library into a shared one with Libtool

前端 未结 2 1721
礼貌的吻别
礼貌的吻别 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.

提交回复
热议问题