conan install --build 由于版本不匹配而失败,即使在更改默认值后也是如此
conan install --build fails due to mismatching versions even after changing default
我正在使用 conan 来处理依赖关系,并且我已经能够通过 运行 单个步骤(如 source
和 build
来编译和 运行 项目。
但是我希望能够一步安装和构建,为此我这样做了:
conan install . -if build -s build_type=Debug --build
在这种情况下,对于某些包,我得到:
Compiler version specified in your conan profile: 10.3
Compiler version detected in CMake: 9.3
Please check your conan profile settings (conan profile show
[default|your_profile_name])
P.S. You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
disable this check.
现在我可以更改配置文件设置以匹配请求的编译器设置,但是其他不同的包开始抱怨编译器版本不匹配。即一些软件包需要 9.3 版,其他需要 10.3 版,其他需要 9 版...
如果我只是 运行 单独构建步骤,考虑到我的可执行文件已经 link 依赖包,我不确定为什么我会得到这个 catch 22 行为。
我尝试在评论中提出建议,将其添加到我的 conanfile.py
def configure(self):
# gcc compiler version
defs = {}
if self.settings.compiler == "gcc":
defs["CMAKE_C_COMPILER"] = f"gcc-{self.settings.compiler.version}"
defs["CMAKE_CXX_COMPILER"] = f"g++-{self.settings.compiler.version}"
# configure cmake
cmake = CMake(self)
cmake.configure(defs = defs)
return super().configure()
我遇到异常。
如果您不告诉 CMake 您要使用的编译器,它将尝试在 project(...)
调用中 发现 它。如果它们不匹配,柯南宏执行的检查将失败。
通常,如果您想使用与默认版本不同的编译器版本,您需要通知 CMake。使用 Conan 配置文件执行此操作的最常见方法之一是将 CC
和 CXX
变量添加到配置文件本身。
[settings]
...
compiler=gcc
compiler.version=10.3
...
[env]
CC=/usr/bin/gcc-10
CXX=/usr/bin/g++-10
Conan 会在调用构建系统之前将这些变量添加到环境中,其中大部分(CMake、Autotools 等)都会将它们考虑在内。
这样,您就不需要修改 conanfile.py
文件。
我正在使用 conan 来处理依赖关系,并且我已经能够通过 运行 单个步骤(如 source
和 build
来编译和 运行 项目。
但是我希望能够一步安装和构建,为此我这样做了:
conan install . -if build -s build_type=Debug --build
在这种情况下,对于某些包,我得到:
Compiler version specified in your conan profile: 10.3
Compiler version detected in CMake: 9.3
Please check your conan profile settings (conan profile show
[default|your_profile_name])
P.S. You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
disable this check.
现在我可以更改配置文件设置以匹配请求的编译器设置,但是其他不同的包开始抱怨编译器版本不匹配。即一些软件包需要 9.3 版,其他需要 10.3 版,其他需要 9 版...
如果我只是 运行 单独构建步骤,考虑到我的可执行文件已经 link 依赖包,我不确定为什么我会得到这个 catch 22 行为。
我尝试在评论中提出建议,将其添加到我的 conanfile.py
def configure(self):
# gcc compiler version
defs = {}
if self.settings.compiler == "gcc":
defs["CMAKE_C_COMPILER"] = f"gcc-{self.settings.compiler.version}"
defs["CMAKE_CXX_COMPILER"] = f"g++-{self.settings.compiler.version}"
# configure cmake
cmake = CMake(self)
cmake.configure(defs = defs)
return super().configure()
我遇到异常。
如果您不告诉 CMake 您要使用的编译器,它将尝试在 project(...)
调用中 发现 它。如果它们不匹配,柯南宏执行的检查将失败。
通常,如果您想使用与默认版本不同的编译器版本,您需要通知 CMake。使用 Conan 配置文件执行此操作的最常见方法之一是将 CC
和 CXX
变量添加到配置文件本身。
[settings]
...
compiler=gcc
compiler.version=10.3
...
[env]
CC=/usr/bin/gcc-10
CXX=/usr/bin/g++-10
Conan 会在调用构建系统之前将这些变量添加到环境中,其中大部分(CMake、Autotools 等)都会将它们考虑在内。
这样,您就不需要修改 conanfile.py
文件。