conan-io / conan-io/docs

[question] How to correctly setup comaptibility() for msvc compiler

Open
#3,840 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
125
Forks
382
Avg merge
22h 39m
Merged PRs (30d)
21

Description

### What is your question?

Hello,

I am using Conan v1.62.0 on Windows 10
I have an upstream mylibrary that i compile for following configuration:
`shared=true with msvc v193 compiler (in VS2022). `
I have a downstream application that links against mylibrary. The application must be built with msvc v190 (also in VS2022). I have tried to link everything **manually** and it compiled and worked.

Inside the upstream mylibrary i have following compatibility function:
```
def compatibility(self):
if self.settings.compiler == "msvc":
return [{"settings": [("compiler.version", v)]}
for v in ("190", "191", "192")]
```
running **conan install** give me following error:
```
Configuration:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=14
compiler.runtime_type=Debug
compiler.version=190
os=Windows
[options]
[build_requires]
[env]
[conf]
tools.microsoft.msbuild:vs_version=17

mylibrary/0.1.0: Compatible package ID 88ae9566af1a1f2192bd6d37261db5b8ec0258f8 equal to the default package ID
conanfile.py: Installing package
Requirements
mylibrary/0.1.0 from local cache - Cache
Packages
mylibrary/0.1.0:88ae9566af1a1f2192bd6d37261db5b8ec0258f8 - Missing

Installing (downloading, building) binaries...
ERROR: Missing binary: mylibrary/0.1.0:88ae9566af1a1f2192bd6d37261db5b8ec0258f8

mylibrary/0.1.0: WARN: Can't find a 'mylibrary/0.1.0' package for the specified settings, options and dependencies:
- Settings: arch=x86_64, build_type=Debug, compiler=msvc, compiler.cppstd=14, compiler.runtime=dynamic, compiler.runtime_type=Debug, compiler.version=190, os=Windows
- Options: shared=True
- Dependencies:
- Requirements:
- Package ID: 88ae9566af1a1f2192bd6d37261db5b8ec0258f8

ERROR: Missing prebuilt package for 'mylibrary/0.1.0'
Use 'conan search mylibrary/0.1.0@ --table=table.html -r=remote' and open the table.html file to see available packages
Or try to build locally from sources with '--build=mylibrary'
```
It seems that Conan recognizes that msvc v193 package is compatible but for some reason still doesn't want to use it.
Any idea how to rewrite compatibility() in order to tell Conan that package built in v193 is compatible for app built with v190?

Thanks

### Have you read the CONTRIBUTING guide?

- [X] I've read the CONTRIBUTING guide

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.