find_library: Prefer .dll.a and .lib over .dll for shared

We can't know if the .lib is a static or import library, but that's
a problem in general too. The only way to figure out if a specific
file is an import or a static library is to dump its symbols and check
if it starts with __imp or not.

Even then, some libs are hybrid import and static, i.e., they contain
references to DLLs for some symbols and also provide implementations
for other symbols so this is a difficult problem.

Closes https://github.com/mesonbuild/meson/issues/2659
This commit is contained in:
Nirbheek Chauhan 2017-11-29 10:44:41 +05:30
parent 390f0b8b52
commit 45dbc0d30e
1 changed files with 3 additions and 1 deletions

View File

@ -727,10 +727,12 @@ class CCompiler(Compiler):
if for_darwin(env.is_cross_build(), env):
shlibext = ['dylib']
elif for_windows(env.is_cross_build(), env):
# FIXME: .lib files can be import or static so we should read the
# file, figure out which one it is, and reject the wrong kind.
if self.id == 'msvc':
shlibext = ['lib']
else:
shlibext = ['dll', 'dll.a', 'lib']
shlibext = ['dll.a', 'lib', 'dll']
# Yep, static libraries can also be foo.lib
stlibext += ['lib']
elif for_cygwin(env.is_cross_build(), env):