Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson seems to append '.lib' to all pkg-config libs on windows #13859

Open
MicK7 opened this issue Nov 3, 2024 · 1 comment
Open

meson seems to append '.lib' to all pkg-config libs on windows #13859

MicK7 opened this issue Nov 3, 2024 · 1 comment

Comments

@MicK7
Copy link

MicK7 commented Nov 3, 2024

Describe the bug

When I add hdf5 as a dependency to a C piece of code on windows, ie `

hdf5_dep = dependency('hdf5', language:'c', required: true)

I end up with a link failure of msvc

FAILED: CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd
"link"  /MACHINE:x64 /OUT:CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/meson-generated_CGNS_MAP_EmbeddedCHLone.pyx.c.obj CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/l3.c.obj CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/error.c.obj CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/linksearch.c.obj CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/sha256.c.obj CGNS/MAP/EmbeddedCHLone.cp310-win_amd64.pyd.p/SIDStoPython.c.obj "/release" "/nologo" "/OPT:REF" "/DLL" "/IMPLIB:CGNS\MAP\EmbeddedCHLone.cp310-win_amd64.lib" "C:\ProgramData\mambaforge\Library\lib\hdf5_hl.lib" "C:/ProgramData/mambaforge/Library/lib/hdf5.lib" "/LIBPATH:C:/ProgramData/mambaforge/Library/lib" "shlwapi.lib" "C:/ProgramData/mambaforge/Library/lib/libcurl.lib.lib" "optimized.lib" "C:/ProgramData/mambaforge/Library/lib/libssl.lib.lib" "debug.lib" "C:/ProgramData/mambaforge/Library/lib/libcrypto.lib.lib" "C:/ProgramData/mambaforge/Library/lib/z.lib.lib" "C:/ProgramData/mambaforge/Library/lib/szip.lib.lib" "C:\ProgramData\mambaforge\libs\python310.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib"
LINK : fatal error LNK1181: cannot open input file 'C:\ProgramData\mambaforge\Library\lib\libcurl.lib.lib'

The hdf5.pc used by meson was generated by a cmake build and contains:

prefix=C:/ProgramData/mambaforge/Library
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: hdf5
Description: HDF5 (Hierarchical Data Format 5) Software Library
Version: 1.14.3

Cflags: -I${includedir}
Libs: -L${libdir}  -lhdf5
Requires:
Libs.private:  -lshlwapi -lC:/ProgramData/mambaforge/Library/lib/libcurl.lib -loptimized -lC:/ProgramData/mambaforge/Library/lib/libssl.lib -ldebug -loptimized -lC:/ProgramData/mambaforge/Library/lib/libcrypto.lib -ldebug -lC:/ProgramData/mambaforge/Library/lib/z.lib -lC:/ProgramData/mambaforge/Library/lib/szip.lib -lC:/ProgramData/mambaforge/Library/lib/szip.lib
Requires.private:

The Libs.private seems to be a part added to the linking and modified by meson by appending a '.lib'

To Reproduce

Create a simple C program that do nothing but contains

#include "hdf5.h"

int main()
{
int a =1;
a = a+2;
return 0;
}

The meson.build should contains

hdf5_dep = dependency('hdf5', language:'c', required: true)

executable('myapp',
main.c,
dependencies: [hdf5_dep]) 

Expected behavior

Linking to hdf5 on windows should work and meson should not append ".lib" when it is already present at end of file.

system parameters

  • plain native build (for the same computer)
  • Windows 10
  • Python version 3.10.0
  • meson --version 1.6.0
  • ninja --version 1.12.1
@rgommers
Copy link
Contributor

rgommers commented Nov 5, 2024

That hd5.pc file seems to be buggy. Including -ldebug -loptimized is certainly wrong. Then, Libs.private still includes a mix of library names with and without .lib appended, because of -lshlwapi. If after removing -ldebug and -loptimized things don't work, can you try changing -lshlwapi to -lshlwapi.lib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants