0
votes

In my shared library foo I link static library bar as follows:

foo_la_LIBADD = /path/to/bar.lib

When linking, I get the following:

*** Warning: Trying to link with static lib archive /path/to/bar.lib.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because the file extensions .lib of this argument makes me believe
*** that it is just a static archive that I should not use here.

and the link fails.

bar.lib is effectively an intermediate convenience archive, but it is not produced by automake.

I can fix the issue by hand-generating a bar.la wrapper for bar.lib with

old_library='bar.lib'
shouldnotlink=no

but that seems like a gruesome hack I would prefer to avoid. Is there a better way to fix this?

1

1 Answers

0
votes

Don't use libtool to link shared libraries on Windows if your library depends on other libraries. If you do, expect at the very least to create .la wrappers for any libraries not produced by autotools.

Instead, you can create and maintain custom link rules for Windows using cl.exe or link.exe directly. You can conditionally specify such rules in your Makefile.am and they will override the default libtool rule. This is far less trouble than fighting with libtool.