【问题标题】:how to make a library with libtool if there are sources with the same filename in several directories如果多个目录中存在具有相同文件名的源,如何使用 libtool 创建库
【发布时间】:2011-01-28 12:53:57
【问题描述】:

我正在尝试使用 libtool 编译一个库。问题是我在几个目录中有几个具有相同文件名的源文件。因此,在 autoreconf 期间,libtoolize 会向我抛出错误。

基本上,我的文件系统布局如下:

src/
    Makefile.am
    file.cpp
    dir1/
        file.cpp
        ...
    dir2/
        file.cpp
        ...

Makefile.am 位于 src/ 目录中,由主 Makefile.am 使用 SUBDIRS = src 调用。内容类似如下:

libfoo_la_SOURCES =    \
    file.cpp        \
    dir1/file.cpp   \
    dir2/file.cpp   \
    ...

但是,在执行 autoreconf 时,我得到一个错误:

src/Makefile.am: object `file.lo' created by `dir1/file.cpp' and `file.cpp'

如何解决?我认为我必须将 Makefile.am 添加到每个子目录中。如何做到这一点?谷歌没有帮助找到解决方案。

【问题讨论】:

    标签: file compiler-construction libtool


    【解决方案1】:

    即使您在构建系统中完成这项工作,静态库仍然会丢失部分代码,因为 ar 很乐意覆盖具有相同名称的存档成员。

    【讨论】:

      【解决方案2】:

      解决方案是在每个子目录中创建方便的 libtool 库(为它们添加前缀,这样它们就不会被安装),然后将它们链接到最终的共享库。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-30
        • 2016-01-05
        • 1970-01-01
        • 2016-07-22
        • 2019-03-04
        • 1970-01-01
        • 2011-02-26
        相关资源
        最近更新 更多