how to make a library with libtool if there are sources with the same filename in several directories

StackOverflow https://stackoverflow.com/questions/4828429

I'm trying to compile a library using libtool. The problem is that I have several source files with the same filename in several directories. Because of the that, during autoreconf, libtoolize throws errors at me.

Basically, my filesystem layout is as follows:

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

The Makefile.am is placed in the src/ directory and is called by the main Makefile.am using SUBDIRS = src. The contents are similar to the following:

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

However, when doing autoreconf, I get an error:

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

How to solve that? I presume that I'll have to add a Makefile.am into each of the subdiectories. How to exactly do that? Google did not help to find the solution.

有帮助吗?

解决方案 2

The solution is to create convenience libtool libraries (prefix them noinst so they won't be installed) in each subdirectory and then link them to the final shared library.

其他提示

Even if you make that work in the build system, the static library will still be missing parts of the code as ar happily overwrites archive members with the same name.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top