automake - 使用 automake 将共享库链接到静态 libtool 库

标签 automake libtool

我有这个目录结构

prog/libA
prog/libB

在 libA 中,我有一个 Makefile.am,如下所示:

noinst_LTLIBRARIES = libA.la
libA_la_SOURCES = ...
libA_la_LIBADD = ... $(LAPACK)

其中 LAPACK 是我系统的 lapack 安装。这按预期工作。但是,在 libB 中我有这个:

noinst_LTLIBRARIES = libB.la
bin_PROGRAMS = compLibB
libB_la_SOURCES = ...
compLibB_SOURCES = ...
libB_LIBADD = $(top_builddir)/libA/libA.la ...
compLibB_LDADD = libB.la

这不起作用。 compLibB 的链接阶段提示对 LAPACK 的 undefined reference ,除非我将最后一行更改为

compLibB_LDADD = libB.la $(LAPACK)

但这似乎是多余的。当我构建 libA.la 便利库时,我不是已经链接到 $(LAPACK) 了吗?这是不干净的,因为现在 compLibB 必须关心 libA 的细节。有没有办法在 libA 构建阶段链接 LAPACK 库,这样我就不必在 compLibB 构建阶段重新指定它?

最佳答案

Haven't I already linked in $(LAPACK) when I build the libA.la convenience lib?

正如您的链接器已经告诉您的那样,不。 libA.la 是一个便利库,有点像静态库(目标文件的集合)。

It's unclean because now compLibB has to concern itself with the details of libA. Is there no way to link in the LAPACK libs at the libA build stage so that I don't have to re-specify it at the compLibB build stage?

构建 libA.la 时,您不需要指定 LAPACK 库,因为最终链接尚未发生。我知道如果不将 libA 设为共享库,就无法完成您想要的任务。

关于automake - 使用 automake 将共享库链接到静态 libtool 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24064903/

相关文章:

fortran - automake 与 fortran : order of file

makefile - 如何在递归自动生成的 Makefile 之间传递变量

c++ - 非标准 C++ 后缀的自动依赖跟踪

objective-c - 如何使用 libtool 在 Mac OS 上创建 .a 文件(静态库)?

macos - 已安装 libtool 但未找到 libtoolize

linux - 使用 automake 设置每个文件的标志

autotools - 自动生成错误: no proper invocation of AM_INIT_AUTOMAKE was found

header-files - 用automake将头文件放在/usr/include的子目录中?

autotools - 如何学习使用autotools/libtool? (也有人不喜欢吗?)

linker - automake 和自定义 rpath