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

[package] <zlib>/<1.2.12>: Can't link #12648

Open
PolarStarWalker opened this issue Aug 27, 2022 · 3 comments
Open

[package] <zlib>/<1.2.12>: Can't link #12648

PolarStarWalker opened this issue Aug 27, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@PolarStarWalker
Copy link

PolarStarWalker commented Aug 27, 2022

Package and Environment Details

  • Package Name/Version: zlib/1.2.12
  • Operating System+version: Windows 10
  • Compiler+version: Clang 14
  • Conan version: conan 1.51.3
  • Python version: Python 3.10.6

Conan profile

[settings]
os=Windows
os.subsystem=msys2
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=14
compiler.libcxx=libc++
compiler.cppstd=20
compiler.runtime=MTd
build_type=Debug
[options]
[conf]
[build_requires]
[env]
C=C:\msys64\clang64\bin\clang.exe
CXX=C:\msys64\clang64\bin\clang++.exe

Steps to reproduce

Linker expects the name libzlib.a
Actual name id directory is libz.a

I guess that the problem here
Name in package_info and actual name of library is different, because _is_clang_cl methond is wrong

my conan file conanfile.txt

[requires]
    zlib/1.2.12
[options]

[generators]
    cmake

[imports]

Logs

Click to expand log
lld: error: unable to find library -lzlib
@PolarStarWalker PolarStarWalker added the bug Something isn't working label Aug 27, 2022
@SpaceIm
Copy link
Contributor

SpaceIm commented Aug 27, 2022

I don't have an elegant fix (except using conan.tools.files.collect_libs()), but this discussion might be of interest for you: conan-io/conan#10955

Basically during zlib build, the output name depends on https://cmake.org/cmake/help/latest/variable/MSVC.html, and this variable is TRUE if the compiler detected by CMake is cl (ie the compiler of Visual Studio), but also any "cl like" compilers.
In package_info() we deduce lib name from this condition, so we have to mimic this condition.
clang-cl is a cl like compiler, thus this _is_clang_cl in this recipe which has been added to handle some issues encoutered by @AndreyMlashkin, but it doesn't make the distinction between clang-cl and clang from MinGW (and actually it's not even clear how a canonical conan profile for clang-cl or even clang from MinGW should look like). clang from MinGW doesn't seem to be a cl like compiler for MSVC variable of CMake, so it breaks.

@calebgray
Copy link

I just ran in to a variation of this same issue with the latest version of zlib (1.2.13), thankfully there's an elegant fix for my issue.

I'm building using a version of mingw that was compiled using clang: https://github.com/mstorsjo/llvm-mingw

This line checks gcc but not clang which leads to an incorrect cpp_info.libs export: https://github.com/conan-io/conan-center-index/blob/master/recipes/zlib/all/conanfile.py#L32

I've forked the repo, and contributed a first pass solution: https://github.com/calebgray/conan-center-index

If/when I'm accepted as a contributor to the project, I'll create a PR for this and continue to follow the CONTRIBUTING guide.

@SpaceIm
Copy link
Contributor

SpaceIm commented Jan 8, 2023

It would break clang-cl. There is PR already: #14644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants