Description
What is your question?
While trying to build Qt 5 with Conan, I ran into an error with one of its dependencies, but only when using build_type=Debug
. There were linker errors with bzip2. To isolate the problem, I cloned the conan-center-index repo and compiled bzip2 on its own with Release
and Debug
as the build types. The test package failed with linker errors for Debug
:
conan-center-index\recipes\bzip2\all> conan test .\test_package\ bzip2/1.0.8 -s build_type=Debug
...
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=192
os=Windows
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=192
os=Windows
...
bzip2/1.0.8 (test package): Running CMake.build()
bzip2/1.0.8 (test package): RUN: cmake --build "C:\Daten\Olive\conan-center-index\recipes\bzip2\all\test_package\build\msvc-192-x86_64-17-debug" --config Debug
Microsoft (R)-Build-Engine, Version 16.11.2+f32259642 für .NET Framework
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
Checking Build System
Building Custom Rule C:/Daten/Olive/conan-center-index/recipes/bzip2/all/test_package/CMakeLists.txt
test_package.c
test_package.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_BZ2_bzBuffToBuffCompress" in Funktion "main". [C:\Daten\Olive\conan-center-index\recipes\bzip2\all\test_package\build\msv
c-192-x86_64-17-debug\test_package.vcxproj]
test_package.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_BZ2_bzlibVersion" in Funktion "main". [C:\Daten\Olive\conan-center-index\recipes\bzip2\all\test_package\build\msvc-192-x8
6_64-17-debug\test_package.vcxproj]
C:\Daten\Olive\conan-center-index\recipes\bzip2\all\test_package\build\msvc-192-x86_64-17-debug\Debug\test_package.exe : fatal error LNK1120: 2 nicht aufgelöste Externe [C:\Daten\Olive\conan-center-index\reci
pes\bzip2\all\test_package\build\msvc-192-x86_64-17-debug\test_package.vcxproj]
It can't resolve symbols __imp_BZ2_bzBuffToBuffCompress
and __imp_BZ2_bzlibVersion
, so none of the functions included from bzlib.h
.
I opened test_package.c
in VSCode for which I have Microsoft's C/C++ extension installed, right-clicked #include "bzlib.h"
, and selected Go to Definition. To my surprise, this didn't open C:\MyFiles\conan-center-index\recipes\bzip2\all\src\bzlib.h
but C:\MyFiles\vcpkg\installed\x64-windows\include\bzlib.h
(from 2020).
After appending an underscore to all the bzip-related files in that vcpkg
folder, I reran the conan test
command and now it succeeded (actually, renaming bzlib.h
seems to be sufficient). I suppose the vcpkg build of bzip2, which happens to be v1.0.8 as well, is somehow incompatible (maybe it is only a Release build). But more importantly, there seems to be a conflict between vcpkg and Conan, and vcpkg takes precedence for some reason.
I'm posting this as a question because this might have been answered elsewhere (but I couldn't find a relevant issue) or there might be a way to circumvent this problem already. If not, please turn this into a feature request.
- Removing everything vcpkg would obviously solve the issue, but vcpkg and Conan may need to co-exist on a system
- VirtualBuildEnv comes to mind, but I checked my environment variables and there is nothing for vcpkg. I think Visual Studio (Code) picks it up because of
%LOCALAPPDATA%\vcpkg\vcpkg.path.txt
, which containsC:/MyFiles/vcpkg
. This has been originally created by me runningvcpkg integrate install
- There is an option in Visual Studio to disable Vcpkg for projects in the solution, which translates to an entry in
build\src\<project-name>.vcxproj
:If Vcpkg is turned off, VS no longer takes the bzip2 header from the vcpkg folder as desired. I guess Conan could make use of this option to avoid clashes? (I think setting it for the top-most project should be enough as the default setting appears to be to inherit the setting of this option from the parent project).<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ... <PropertyGroup Label="Vcpkg"> <VcpkgEnabled>false</VcpkgEnabled> </PropertyGroup>
Have you read the CONTRIBUTING guide?
- I've read the CONTRIBUTING guide