Force linking a static library into a shared one with Libtool

99封情书 提交于 2019-12-04 01:26:30

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!