conan-io / conan-center-index

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

[package] opengl/system & ffmpeg/6.1: pkg-config errors when pkg-config not installed #23009

Open irieger opened 6 months ago

irieger commented 6 months ago

Description

I was running into problems with the two libraries mentioned in the title: opengl/system as well as ffmpeg/6.1. For my build pipeline, I setup a absolutely minimal Docker-Container with Ubuntu 22.04, with basically only python & build-essential (and later libgl-dev or now libopengl-dev).

What I would suggest is to ensure that proper error messages are thrown if pkg-config is not available in the system and that it needs to be installed manually. I can perfectly life with having to do it manually, but debugging why the process failed was costing me some time that I'd like to spare others from spending.

Conan for installing opengl/system + glew/* was running into roughly the following output:

/bin/sh: 1: pkg-config: not found
ERROR: Traceback (most recent call last):
  File "/home/venv/lib/python3.10/site-packages/conans/errors.py", line 52, in conanfile_exception_formatter
    yield
  File "/home/venv/lib/python3.10/site-packages/conans/client/installer.py", line 415, in _call_package_info
    conanfile.package_info()
  File "/home/.conan2/p/opengc3fc46f257b85/e/conanfile.py", line 61, in package_info
    pkg_config.fill_cpp_info(self.cpp_info, is_system=self.settings.os != "FreeBSD")
...

(Here I might have gotten the clue, but I thought conan takes care of tools, so getting an error message by Conan, that tells me that I need to ensure my system has pkg-config would have greatly helped!)

It is much more hidden in ffmpeg(/6.1). There I just had the build process to show me an error in finding a library:

ffmpeg/6.1: Building from source
ffmpeg/6.1: Package ffmpeg/6.1:3574d0639fd06f016b2f884920315d25ed611a89
ffmpeg/6.1: Copying sources to build folder
ffmpeg/6.1: Building your package in /home/.conan2/p/b/ffmpe993a1e1dc8239/b
ffmpeg/6.1: Calling generate()
ffmpeg/6.1: Generators folder: /home/.conan2/p/b/ffmpe993a1e1dc8239/b/build-debug/conan
ffmpeg/6.1: Generating aggregated env files
ffmpeg/6.1: Generated aggregated env files: ['conanbuild.sh']
ffmpeg/6.1: Calling build()
ffmpeg/6.1: Calling:
 > "/home/.conan2/p/b/ffmpe993a1e1dc8239/b/src/configure" --enable-shared --disable-static --prefix=/ '--bindir=${prefix}/bin' '--libdir=${prefix}/lib' --pkg-config-flags=--static --disable-doc --disable-cross-compile --enable-asm --enable-shared --disable-static --enable-pic --disable-avdevice --enable-avcodec --enable-avformat --enable-swresample --enable-swscale --enable-postproc --enable-avfilter --enable-bzlib --enable-zlib --enable-lzma --enable-iconv --enable-libopenjpeg --enable-libopenh264 --enable-libvorbis --enable-libopus --disable-libzmq --disable-sdl2 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libfdk-aac --enable-libwebp --enable-libaom --enable-openssl --disable-alsa --disable-libpulse --disable-vaapi --disable-vdpau --disable-libxcb --disable-libxcb-shm --disable-libxcb-shape --disable-libxcb-xfixes --disable-appkit --disable-avfoundation --disable-coreimage --disable-audiotoolbox --disable-videotoolbox --disable-securetransport --disable-cuda --disable-cuvid --enable-nonfree --enable-gpl --disable-vulkan --enable-libsvtav1 --enable-libdav1d --arch=x86_64 --disable-optimizations --disable-mmx --disable-stripping --enable-debug --cc=gcc --cxx=g++ '--extra-cflags=-m64 -g' --extra-ldflags=-m64 
ffmpeg/6.1: RUN: "/home/.conan2/p/b/ffmpe993a1e1dc8239/b/src/configure" --enable-shared --disable-static --prefix=/ '--bindir=${prefix}/bin' '--libdir=${prefix}/lib' --pkg-config-flags=--static --disable-doc --disable-cross-compile --enable-asm --enable-shared --disable-static --enable-pic --disable-avdevice --enable-avcodec --enable-avformat --enable-swresample --enable-swscale --enable-postproc --enable-avfilter --enable-bzlib --enable-zlib --enable-lzma --enable-iconv --enable-libopenjpeg --enable-libopenh264 --enable-libvorbis --enable-libopus --disable-libzmq --disable-sdl2 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libfdk-aac --enable-libwebp --enable-libaom --enable-openssl --disable-alsa --disable-libpulse --disable-vaapi --disable-vdpau --disable-libxcb --disable-libxcb-shm --disable-libxcb-shape --disable-libxcb-xfixes --disable-appkit --disable-avfoundation --disable-coreimage --disable-audiotoolbox --disable-videotoolbox --disable-securetransport --disable-cuda --disable-cuvid --enable-nonfree --enable-gpl --disable-vulkan --enable-libsvtav1 --enable-libdav1d --arch=x86_64 --disable-optimizations --disable-mmx --disable-stripping --enable-debug --cc=gcc --cxx=g++ '--extra-cflags=-m64 -g' --extra-ldflags=-m64 
ERROR: aom >= 1.0.0 not found using pkg-config
If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
ffmpeg/6.1: ERROR: 
Package '3574d0639fd06f016b2f884920315d25ed611a89' build failed
ffmpeg/6.1: WARN: Build folder /home/.conan2/p/b/ffmpe993a1e1dc8239/b/build-debug
ERROR: Traceback (most recent call last):
  File "/home/venv/lib/python3.10/site-packages/conans/errors.py", line 52, in conanfile_exception_formatter
    yield
  File "/home/venv/lib/python3.10/site-packages/conans/client/conanfile/build.py", line 14, in run_build_method
    conanfile.build()
  File "/home/.conan2/p/ffmpe4d78cb7ece53e/e/conanfile.py", line 710, in build
    autotools.configure()
  File "/home/venv/lib/python3.10/site-packages/conan/tools/gnu/autotools.py", line 59, in configure
    self._conanfile.run(cmd)
  File "/home/venv/lib/python3.10/site-packages/conans/model/conan_file.py", line 342, in run
    raise ConanException("Error %d while executing" % retcode)
conans.errors.ConanException: Error 1 while executing

So as said, my idea would be, that we should ensure the user gets a helpful error.

Package and Environment Details

Conan profile

[settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=20 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux

Steps to reproduce

Create docker container with

# Download base image ubuntu 22.04
FROM ubuntu:22.04

# Update Ubuntu Software repository
RUN apt update
RUN apt upgrade -y

# Install build deps
RUN apt install -y python3-venv python3-pip \
                   build-essential nano \
                   libopengl-dev libglu1-mesa-dev
# Here it should also have pkg-config as I learned the hard way
docker build -t conan-demo-container "Folder with content from above as Dockerfile"
docker run --rm -it conan-demo-container bash
python3 -m venv conan_venv
./conan_venv/bin/pip install -U pip conan cmake
# (Not sure if cmake would be needed in this context)
./conan_venv/bin/conan profile detect

Put the following in a conanfile.txt:

[requires]
opengl/system
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout

Then just run ./conan_venv/bin/conan install PATH_TO_CONANFILE.txt --build=missing

Logs

Click to expand log ``` ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=20 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux Profile build: [settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=20 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux ======== Computing dependency graph ======== opengl/system: Not found in local cache, looking in remotes... opengl/system: Checking remote: conancenter opengl/system: Downloaded recipe revision b29589c04d6df84c110d6acb066ab653 Graph root conanfile.txt: /root/test/conanfile.txt Requirements opengl/system#b29589c04d6df84c110d6acb066ab653 - Downloaded (conancenter) ======== Computing necessary packages ======== Requirements opengl/system#b29589c04d6df84c110d6acb066ab653:da39a3ee5e6b4b0d3255bfef95601890afd80709#0ba8627bd47edc3a501e8f0eb9a79e5e - Download (conancenter) opengl/system: System requirements: already installed ======== Installing packages ======== -------- Downloading 1 package -------- opengl/system: Retrieving package da39a3ee5e6b4b0d3255bfef95601890afd80709 from remote 'conancenter' opengl/system: Package installed da39a3ee5e6b4b0d3255bfef95601890afd80709 opengl/system: Downloaded package revision 0ba8627bd47edc3a501e8f0eb9a79e5e /bin/sh: 1: pkg-config: not found ERROR: opengl/system: Error in package_info() method, line 61 pkg_config.fill_cpp_info(self.cpp_info, is_system=self.settings.os != "FreeBSD") ConanException: Error 127 while executing ```
SpaceIm commented 6 months ago

Duplicate of https://github.com/conan-io/conan-center-index/issues/14909

uilianries commented 1 month ago

The pkg-config is now listed and build required for ffmpeg:

https://github.com/conan-io/conan-center-index/blob/fc9799aba6aecf9daf648f2b1b9d12cc85a51976/recipes/ffmpeg/all/conanfile.py#L366

Please, feel free to re-open this issue in case finding any related to error.

uilianries commented 1 month ago

Re-opening this issue because only tool_requires is not enough as commented here: https://github.com/conan-io/conan/issues/14422#issuecomment-1665166761