编辑
2023-06-25
工具
00
请注意,本文编写于 330 天前,最后修改于 330 天前,其中某些信息可能已经过时。

C++常用的包管理工具有vcpkg,CPM,conan。本文主要记录Ubuntu下的cmake中使用conan的ffmpeg使用方法以及采坑。

下载地址 https://conan.io/downloads.html

安装完成:

conan -v #出现 Conan version 2.0.7

跟着官网的文档:https://docs.conan.io/2.0/tutorial/consuming_packages/build_simple_cmake_project.html 写一个conanfile.txt

[requires] ffmpeg/5.1 [generators] cmake [settings] compiler=g++

如果刚安装完conan,但未使用,先初始化一下: conan profile detect --force 出了警告

$ conan profile detect --force Found gcc 7 gcc>=5, using the major as version gcc C++ standard library: libstdc++11 Detected profile: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu14 compiler.libcxx=libstdc++11 compiler.version=7 os=Linux WARN: This profile is a guess of your environment, please check it. WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions. WARN: Use your own profile files for stability. Saving detected profile to ~/.conan2/profiles/default

直接install命令 conan install . --output-folder=build --build=missing 很不幸,报错了

$ conan install . --output-folder=build --build=missing ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu14 compiler.libcxx=libstdc++11 compiler.version=7 os=Linux Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu14 compiler.libcxx=libstdc++11 compiler.version=7 os=Linux ERROR: <your project path>: ConfigParser: Unrecognized field 'settings'

然后修改conanfile.txt,去掉settings

[requires] ffmpeg/5.1 [generators] cmake

再次 conan install . --output-folder=build --build=missing 很不幸,再次报错

Skipped binaries meson/1.0.0, ninja/1.11.1 vaapi/system: RUN: dpkg-query -W -f='${Status}' libva-dev | grep -q "ok installed" dpkg-query: 没有找到与 libva-dev 相匹配的软件包 ERROR: vaapi/system: Error in system_requirements() method, line 38 apt.install(["libva-dev"], update=True, check=True) ConanException: System requirements: 'libva-dev' are missing but can't install because tools.system.package_manager:mode is 'check'.Please update packages manually or set 'tools.system.package_manager:mode' to 'install' in the [conf] section of the profile, or in the command line using '-c tools.system.package_manager:mode=install'

方法一:尝试现在手动安装:

sudo apt update sudo apt install libva-dev

经过多次实践,需要好几个包

sudo apt-get install libva-dev libvdpau-dev libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-dri3-dev uuid-dev libxcb-cursor-dev libxcb-util-dev libxcb-util0-dev -y

方法二(废案):conan install加上参数 -c tools.system.package_manager:mode=install

即再执行conan install . --output-folder=build --build=missing -c tools.system.package_manager:mode=install

这里看起来有危险操作,尚未加sudo权限。

vaapi/system: System requirements: already installed vdpau/system: RUN: dpkg-query -W -f='${Status}' libvdpau-dev | grep -q "ok installed" dpkg-query: 没有找到与 libvdpau-dev 相匹配的软件包 vdpau/system: RUN: apt-get update 正在读取软件包列表... 完成 E: 无法打开锁文件 /var/lib/apt/lists/lock - open (13: 权限不够) E: 无法对目录 /var/lib/apt/lists/ 加锁 W: 用 unlink 删除文件 /var/cache/apt/pkgcache.bin 出错 - RemoveCaches (13: 权限不够) W: 用 unlink 删除文件 /var/cache/apt/srcpkgcache.bin 出错 - RemoveCaches (13: 权限不够) ERROR: vdpau/system: Error in system_requirements() method, line 38 apt.install(["libvdpau-dev"], update=True, check=True) ConanException: Command 'apt-get update' failed

本文作者:phae

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!