Reputation: 1
I want to use the ffmpeg libraries in my program. These are libavformat and libavcodec. To link them, I'm trying to use pkg-config.
I cannot get pkg-config to find these libraries.
When I run
pkg-config --modversion libavcodec
I get
Can't find libavcodec.pc in any of C:/Strawberry/c/lib/pkgconfig
Which should mean that I don't have ffmpeg installed.
However, I did install ffmpeg. I'm using Windows so I installed ffmpeg with the Chocolatey package manager. This seems to have only given me the ffmpeg program and not its libraries.
On MacOS simply using homebrew to install ffmpeg installs all the right files.
Is there a difference on Windows? How can I get the dev package?
SOME MORE INFO:
I'm compiling this using CMake-js as a node addon. This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.9)
project(FFMpeg)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
pkg_check_modules(AVFILTER REQUIRED IMPORTED_TARGET libavformat)
pkg_check_modules(AVDEVICE REQUIRED IMPORTED_TARGET libavdevice)
pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil)
pkg_check_modules(SWRESAMPLE REQUIRED IMPORTED_TARGET libswresample)
pkg_check_modules(SWSCALE REQUIRED IMPORTED_TARGET libswscale)
add_library(FFMpeg INTERFACE IMPORTED GLOBAL)
target_include_directories(
FFmpeg INTERFACE
${AVCODEC_INCLUDE_DIRS}
${AVFILTER_INCLUDE_DIRS}
${AVDEVICE_INCLUDE_DIRS}
${AVUTIL_INCLUDE_DIRS}
${SWRESAMPLE_INCLUDE_DIRS}
${SWSCALE_INCLUDE_DIRS}
)
target_link_options(
FFmpeg INTERFACE
${AVCODEC_LDFLAGS}
${AVFILTER_LDFLAGS}
${AVDEVICE_LDFLAGS}
${AVUTIL_LDFLAGS}
${SWRESAMPLE_LDFLAGS}
${SWSCALE_LDFLAGS}
I also found this in the output, which might explain why pkg-config is looking in C:\Strawberry?
-- Found PkgConfig: C:/Strawberry/perl/bin/pkg-config.bat (found version "0.26")
-- Checking for module 'libavcodec'
-- Can't find libavcodec.pc in any of C:/Strawberry/c/lib/pkgconfig
Upvotes: 0
Views: 971
Reputation: 1
Cmake looks for those *.pc
files like libavcodec.pc
in C:/Strawberry/c/lib/pkgconfig/
. You need to specify this path before any cmake
or any autoconfig commands into PKG_CONFIG_PATH
variable when building any of those libraries in pkg_check_modules
arguments.
You may do it like: PKG_CONFIG_PATH=C:/Strawberry/c/lib/pkgconfig cmake ..
Upvotes: 0
Reputation: 1
For anyone with the same problem:
I looked at the folder structure of the linux and macos packages, and they include all the libraries. The Windows version that is included in the main download or any package manager does not contain these libraries.
If you're on Windows you will want a build from here (BtbN FFmpeg Builds) and get the full version.
Now all I have to do is get it to work with pkg-config.
Upvotes: 0