conan icon indicating copy to clipboard operation
conan copied to clipboard

Conflict for library libiconv requested by both libarchive and boost

Open iradization opened this issue 3 years ago • 2 comments
trafficstars

Hi, I'm using Conan for fetching some 3rd party libraries into my project. amongst are boost and libarchive. Recently, I've advanced the version of those 2 libraries in Conan.txt, and now getting the following error.

ERROR: Conflict in libarchive/3.6.1:
    'libarchive/3.6.1' requires 'libiconv/1.17' while 'boost/1.79.0' requires 'libiconv/1.16'.
    To fix this conflict you need to override the package 'libiconv' in your root package.

Perhaps anyone can explain me how exactly should I resolve this conflict... I understand that both libraries have libiconv as dependency but with different version - but there must be a way to have different version of libiconv on the same target, right?

I'm using Conan cmake API in the following way :

  conan_cmake_configure(
    REQUIRES
    boost/1.79.0
    libarchive/3.6.1
    GENERATORS
    cmake_find_package)

conan_cmake_autodetect(settings)

    PATH_OR_REFERENCE
    .
    BUILD
    missing
    REMOTE
    conancenter
    SETTINGS
    ${settings})

iradization avatar Aug 02 '22 15:08 iradization

Hi @iradization,

The best you could do to resolve that conflict is to switch from using conan_cmake_configure to explicitly create a conanfile.py and add a requirements() method where you use the argument override=True for the libiconv requirement, that will make both boost and libarchive use the same version of libiconv.

That would mean first creating a conanfile.py to consume those libraries:

class MyProject(ConanFile):
   settings = "os", "compiler", "build_type", "arch"
   generators = "cmake_find_package"

  def requirements(self):
      self.requires("libiconv/1.17", override=True) # this is not an actual requirement, but something to be passed upstream and override possible existing values. 
      self.requires("boost/1.79.0")
      self.requires("libarchive/3.6.1")

Then in your call to conan_cmake_install, explicitly use that conanfile.py:

conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR}/conanfile.py
                    GENERATOR ...)

Hope this helps.

czoido avatar Aug 02 '22 15:08 czoido

Hi @czoido , looks like your method worked. thanks !

However, after try to run the Conan cmake file for arm64 (I'm using M1 macOS), I get the following error

boost/1.79.0: WARN: Boost component 'stacktrace_addr2line' is missing libraries. Try building boost with '-o boost:without_stacktrace_addr2line'. (Option is not guaranteed to exist)
boost/1.79.0: WARN: Boost component 'stacktrace_backtrace' is missing libraries. Try building boost with '-o boost:without_stacktrace_backtrace'. (Option is not guaranteed to exist)
ERROR: boost/1.79.0: Error in package_info() method, line 1664
	raise ConanException("These libraries were expected to be built, but were not built: {}".format(non_built))
	ConanException: These libraries were expected to be built, but were not built: {'boost_stacktrace_addr2line', 'boost_stacktrace_backtrace'}

Perhaps it's the result of updating libiconv from 1.16 to 1.17 ? Any idea how can I avoid those 2 targets ?

Or maybe, the most suitable way, would be to allow both libarchive 1.16 and 1.17 to co-exist so that each target will choose its own desired version.

iradization avatar Aug 03 '22 16:08 iradization