conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
946 stars 1.72k forks source link

[libpng] libpng/1.6.37: invalid library name on windows (msvc) #18165

Open SergeyKrivohatskiy opened 1 year ago

SergeyKrivohatskiy commented 1 year ago

Description

Starting from this commit https://github.com/conan-io/conan-center-index/commit/180aef37e79e790708a96133c33d374eaf7a8f93

there is mismatch in libpng library name.

It Cmake it is: set(CONAN_LIBS_LIBPNG libpng16_static) Actual build artifact name is: libpng16

It leads to a linker error when trying to link to libpng: LINK : fatal error LNK1181: cannot open input file 'libpng16_static.lib'

I believe this will also affect the ones using any package depending on libpng (like opencv).

Package and Environment Details

Conan profile

[settings] os=Windows os_build=Windows arch=x86_64 arch_build=x86_64 compiler=Visual Studio compiler.version=14 build_type=Release

Steps to reproduce


Logs


jcar87 commented 1 year ago

Hi @SergeyKrivohatskiy , thank you for reporting this issue.

Could you provide a reproducible minimal reproducible CMakeLists.txt ?

SergeyKrivohatskiy commented 1 year ago

Rebuilding package helped (the actual lib name is libpng16_static now). Unfortunately I have to manually specify -b=libpng for it to work.

I guess this issue can be closed, but it's still a bad thing that it didn't rebuild the package on its own.

Chnossos commented 1 year ago

No it shouldn't be closed, because it is broken. Our CI cannot build packages requiring Qt 5 anymore due to this problem.

Looking at the recipe, it seems a step like suffix += "_static" if not self.options.shared else "" is missing, but I cannot tell yet if that would be enough or if it should be enclosed in some other condition.

jcar87 commented 1 year ago

Hi @Chnossos - could you attach which commands you are running are which build errors you are getting? thanks!

Chnossos commented 1 year ago

We're basically doing a conan create on one of our library that has a dependency on qt/5.15.2, with no specific flags.

Conan version is 1.60.1.

Configuration:

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
[conf]

Generators are CMakeToolchain + CMakeDeps.

Here is the interesting excerpt from CMake logs:

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.14393.
-- The C compiler identification is MSVC 19.16.27048.0
-- The CXX compiler identification is MSVC 19.16.27048.0
...
-- Conan: Target declared 'PNG::PNG'
CMake Error at build/generators/cmakedeps_macros.cmake:39 (message):
  Library 'libpng16_static' not found in package.  If 'libpng16_static' is a
  system library, declare it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  build/generators/PNG-Target-release.cmake:24 (conan_package_library_targets)
  build/generators/PNGTargets.cmake:26 (include)
  build/generators/PNGConfig.cmake:16 (include)
  C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  build/generators/freetype-config.cmake:24 (find_dependency)
  C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  build/generators/Qt5Config.cmake:24 (find_dependency)
  src/CMakeLists.txt:1 (find_package)
-- Configuring incomplete, errors occurred!

Do note that there is no error when building with MSVC 16 (VS 2019)!

Chnossos commented 1 year ago

I have tried installing the VS Build Tools 2017 on a clean machine but I get other errors: Conan cannot find binaries for libpng/1.6.37 for the specified profile, and indeed there is a binary package available for compiler.runtime=MDd but not for compiler.runtime=MD!

Same with libfreetype/2.12.1.

Adding -b missing to the conan create command makes everything build successfully.

Kaffeine commented 2 months ago

The issue is still presenting.