anon
anon

Reputation:

PKG_CONFIG_PATH A required package was not found

I want to link my C++ app with any library, for example with libavcodec.so. I tried Method I from https://stackoverflow.com/a/44489201/7915017

set(CMAKE_PREFIX_PATH ${pkgconfig_path})

But when I try to build

cmake -S Qt_FFMpeg/src/ -B Qt_FFMpeg/build-host/ --fresh

I get error "A required package was not found". Ok, I try Method II

set(ENV{PKG_CONFIG_PATH} ${pkgconfig_path})

And it works. Why doesn't Method I work? Full code here

I use Ubuntu 22 x86_64, cmake 3.26.4

Upvotes: -1

Views: 612

Answers (1)

Now works! Thanks @Tsyvarev

With Environment Variables

cmake_path(SET pkgconfig_path "${CMAKE_CURRENT_LIST_DIR}/../../FFMpeg_themself/ffmpeg_build/lib/pkgconfig/" NORMALIZE)
set(ENV{PKG_CONFIG_PATH} ${pkgconfig_path})
message("I found $ENV{PKG_CONFIG_PATH}")

Without Environment Variables

cmake_path(SET pkgconfig_path "${CMAKE_CURRENT_LIST_DIR}/../../FFMpeg_themself/ffmpeg_build/" NORMALIZE)
set(CMAKE_PREFIX_PATH ${pkgconfig_path})
message("I found ${CMAKE_PREFIX_PATH}")

Upvotes: 0

Related Questions