Cross compiling fontconfig for iOS - ios

How to cross compiling for fontconfig for iOS.
http://freedesktop.org/software/fontconfig/release
I try this:
./configure
CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -arch armv7"
--sysconfdir=/Users/bluefish625/Desktop/fontconfig/sysconfdir/
--prefix=/Users/bluefish625/Desktop/fontconfig/prefix/
--mandir=/Users/bluefish625/Desktop/fontconfig/mandir
--disable-shared
--host=armv7-apple-darwin
--with-freetype-config=$PREFIX/bin/freetype-config
The error info is:
configure: error: in `/Users/bluefish625/Downloads/fontconfig-2.9.0':
configure: error: The pkg-config script could not be found or is too old.
Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config.
Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details
And,I don't know what this --with-freetype-config means?
can somebody help me? thanks.

Try with this:
export IOS_PLATFORMDIR="/Developer/Platforms/iPhoneOS.platform"
export IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS5.0.sdk"
export IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
export IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
./configure --host arm-apple-darwin10 --disable-docs --enable-shared=no \
--with-expat="/Users/meox/PODOFO/expat" \
--with-expat-includes="/Users/meox/PODOFO/expat/include" \
--with-expat-lib="/Users/meox/PODOFO/expat" \
CC="$IOS_GCC" LD="$IOS_GCC" \
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS
-L/Users/meox/PODOFO/freetype2 -L/Users/meox/PODOFO/expat
-L/Users/meox/PODOFO/zlib -L/Users/meox/PODOFO/libiconv
-L/Users/meox/PODOFO/bzip2" \
CPPFLAGS="-I/Users/meox/PODOFO/freetype2/include
-I/Users/meox/PODOFO/zlib/include -I/Users/meox/PODOFO/expat/include"
You have to set the right paths.

Related

Linking Boost static libraries

I am trying to compile a shared library using static libraries from Boost and OpenCV. Here below the command I am using to compile my library.
g++ -fPIC libsaliency.cpp -shared -o libsaliency.so \
-I/home/poiesi/data/libraries/boost_1_66_0/installed_w_contrib_static/include -I/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/include \
-Wl,--whole-archive \
/home/poiesi/data/libraries/boost_1_66_0/installed/lib/libboost_graph.a \
/home/poiesi/data/libraries/boost_1_66_0/installed/lib/libboost_filesystem.a \
/home/poiesi/data/libraries/boost_1_66_0/installed/lib/libboost_system.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_core.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_highgui.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_imgproc.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_imgcodecs.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_features2d.a \
/home/poiesi/data/libraries/opencv-3.4.0/installed_w_contrib_static/lib/libopencv_video.a \
-Wl,--no-whole-archive
However, I have this error:
usr/bin/ld: /home/poiesi/data/libraries/boost_1_66_0/installed/lib/libboost_graph.a(read_graphviz_new.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/home/poiesi/data/libraries/boost_1_66_0/installed/lib/libboost_graph.a(read_graphviz_new.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:7: recipe for target 'saliency' failed
make: *** [saliency] Error 1
Does this mean I have to recompile Boost using -fPIC command? I checked this online but I haven't found much info about it. This makes me wonder if I am searching for the right thing. Do you have any suggestion?
EDIT: As suggested below by Mike, I recompiled Boost like this:
./b2 cxxflags="-fPIC" link=static install
and I can now compile my .so library.
Does this mean I have to recompile Boost using -fPIC command?
Yes. All code that is linked into a shared library must be Position Independent Code. Object
files within static libraries normally are not, as shared libraries normally
link other shared libraries.
But there is nothing in principle to stop you from building boost static libraries
from -fPIC-compiled object files.
It would be simpler, of course, to link the shared versions of the boost libraries.
With boost 1.72.0, fixed this problem by recompile boost static library with -fPIC.
./bootstrap.sh --prefix=/usr/
sudo ./b2 cxxflags=-fPIC cflags=-fPIC link=static -a
sudo ./b2 install

Cross-compiling on Linux for iOS

I am trying to cross-compile Ruby for iOS devices. I have a rather lengthy script that downloads the latest source code for Ruby, unzips it, and compiles it.
The script is as follows:
#!/bin/bash
rm -rf ~/built/ruby
AR=~/toolchain/armv7-apple-darwin11-ar
AS=~/toolchain/armv7-apple-darwin11-as
CC=~/toolchain/armv7-apple-darwin11-clang
CXX=~/toolchain/armv7-apple-darwin11-clang++
LD=~/toolchain/armv7-apple-darwin11-ld
NM=~/toolchain/armv7-apple-darwin11-nm
OBJDUMP=~/toolchain/armv7-apple-darwin11-objdump
RANLIB=~/toolchain/armv7-apple-darwin11-ranlib
STRIP=~/toolchain/armv7-apple-darwin11-strip
SDK=/home/citrusui/sdks/iPhoneOS9.3.sdk
CFLAGS="-arch armv7 -arch arm64 -isysroot $SDK"
LDFLAGS="-Wl,-segalign,4000"
DESTDIR=~/built/ruby/var/stash
apt install autoconf bison clang jq xutils-dev
curl https://api.github.com/repos/ruby/ruby/tags -o ruby.json
URL=`jq -r 'map(select(.name != "yarv_migration_base"))[0].tarball_url' ruby.json`
TAG=`jq -r 'map(select(.name != "yarv_migration_base"))[0].name' ruby.json`
echo "Downloading from $URL"...
if [ -f ruby_$TAG.tar.gz ] && [ -d ruby-ruby* ]; then
echo "Already downloaded."
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR"
make install -j4
cd ~/built/ruby
lndir var/stash
exit 0
fi
curl -L $URL -o ruby_$TAG.tar.gz
tar -xvzf ruby_$TAG.tar.gz
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR"
make install -j4
cd ~/built/ruby
lndir var/stash
Now, I have also downloaded the iOS 9.3 SDK from Xcode and dropped it into my ~/sdks/ folder. However, the compiling process still results in ELF format binaries.
I also have a toolchain (in ~/toolchain/) downloaded from here. I assume this will allow LLVM/Clang to produce arm(64) binaries, but I don't know how I would tell clang to process this toolchain. Specifying $TOOLCHAIN in ./configure doesn't help, either.

FFMPEG iOS 7 Library

I've tried reading many tutorials.
I've spent hours on google, and stackoverflow trying answer.
So far I've read: Trying to compile the FFMPEG libraries for iPhoneOS platform with armv6 and arv7 architecture FFMPEG integration on iphone/ ipad project and https://github.com/lajos/iFrameExtractor few of the many.
I'm trying to build this library for iOS 7/Xcode 5 compatibility but it's not working.
A common error I'd get is:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
yasm/nasm not found or too old. Use --disable-yasm for a crippled build.
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.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
I'd also get many more once that is finished. Such as:
rm: illegal option -- .
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
make: *** [clean] Error 64
I've mostly tried using this command to start, but it always crashes on "make clean":
./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk' \
--prefix=compiled/armv7 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug
To use the mooncatventures (our) ffmpegdecoderFramework, go into build settings
click on the arch and remove the armv7s.
you must also change build active architechure only to no.
This answer from mientus worked for me :
https://stackoverflow.com/a/19370679/661720
Support universal ffmpeg library for iOS7 and XCode5:
Install gas-preprocessor
Click on the ZIP icon to download
https://github.com/mansr/gas-preprocessor. Copy gas-preprocessor.pl to
/usr/bin directory. Change permission of gas-preprocessor.pl by
setting the privilege to Read & Write for all.
Download my shell script from: https://gist.github.com/m1entus/6983547
Run sh build-ffmpeg.sh.

How to build GLib for iOS

I want to use lasem in my iOS App, but compiling lasem needs glib. How to build it?
I download glib-2.37.4 from https://git.gnome.org/browse/glib/refs/tags. I then used autogen.sh to get a configure file, ran make and installed on mac. I wrote a shell script try to build glib for iOS, as blow:
export path=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/:$path
export CC=arm-apple-darwin10-llvm-gcc-4.2
export CFLAGS="-arch armv7"
export LDFLAGS="-miphoneos-version-min=2.0"
export LD="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld--disable-cxx"
./configure --prefix=/usr/local/ios/ --host=arm-apple-darwin10 --enable-static=yes --enable-shared=no CC=$CC CFLAGS=$CFLAGS CPP=cpp AR=ar LDFLAGS=$LDFLAGS LD=$LD
When I run this script, return as:
checking for arm-apple-darwin10-gcc... arm-apple-darwin10-llvm-gcc-4.2
checking whether the C compiler works... no
configure: error: in `/Users/tinyfool/Downloads/glib-2.34.3':
configure: error: C compiler cannot create executables
What can I do?
Given that you have built libffi and proxy-libintl for iOS, and installed both those to the same PREFIX as this script uses, this will build GLib for you:
#! /bin/bash
export MINVER="5.1" # the minimum supported OS version
export SDKVER="5.1" # SDK version
export PREFIX="$HOME/built-for-ios" # where the library goes
export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk"
export PKG_CONFIG_LIBDIR="${PREFIX}/lib/pkgconfig:${SDKROOT}/usr/lib/pkgconfig"
export COMMON_FLAGS="-arch armv7 -isysroot ${SDKROOT}"
export CPPFLAGS="-I${PREFIX}/include ${COMMON_FLAGS} -miphoneos-version-min=${MINVER}"
export CFLAGS="${CPPFLAGS}"
export LDFLAGS="-L${PREFIX}/lib ${COMMON_FLAGS} -Wl,-iphoneos_version_min,${MINVER}"
export CC="${DEVROOT}/usr/bin/gcc"
export CXX="${DEVROOT}/usr/bin/g++"
export OBJC="${CC}"
export LD="${CC}"
[ ! -d "${PREFIX}" ] && mkdir -p "${PREFIX}"
./configure --prefix="${PREFIX}" \
--build="x86_64-apple-darwin" \
--host="arm-apple-darwin" \
--enable-static \
--disable-shared \
glib_cv_stack_grows=no \
glib_cv_uscore=no \
ac_cv_func_posix_getgrgid_r=yes \
ac_cv_func_posix_getpwuid_r=yes

Package opencv was not found in the pkg-config search path

I have installed OpenCV using the instructions in https://help.ubuntu.com/community/OpenCV
$ sudo su
$ sudo apt-get install build-essential
$ sudo apt-get install libavformat-dev
$ sudo apt-get install ffmpeg
$ sudo apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev
now when i execute "pkg-config --cflags --libs opencv" i get this error:
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
how can I resolve this problem?
-------UPDATE-------
OK, I figured out how to solve the problem...
I made a file named "opencv.pc" and copied it to "/usr/local/lib/pkgconfig"
Then i added these two lines to ".bashrc":
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
that's it! everything is OK now.
the contents of the file are:
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: opencv
Description: The opencv library
Version: 2.x.x
Cflags: -I${includedir}/opencv -I${includedir}/opencv2
Libs: -L${libdir} -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -lopencv_core -lopencv_ml -lopencv_features2d -lopencv_objdetect -lopencv_flann -lopencv_video -lopencv_highgui
UPDATE - 2014
it seems that the ubuntu community has completed the documentation on installing openCV, all you have to do now is to download the installation script from https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/opencv_latest.sh and execute it.
From your question I guess you are using Ubuntu (or a derivate).
If you use:
apt-file search opencv.pc
then you see that you have to install libopencv-dev.
After you do so, pkg-config --cflags opencv and pkg-config --libs opencv should work as expected.
with opencv 4.0;
add -DOPENCV_GENERATE_PKGCONFIG=ON to build arguments
pkg-config --cflags --libs opencv4 instead of opencv
When you run cmake add the additional parameter -D OPENCV_GENERATE_PKGCONFIG=YES
(this will generate opencv.pc file)
Then make and sudo make install as before.
Use the name opencv4 instead of just opencv Eg:-
pkg-config --modversion opencv4
it seems that the ubuntu community has completed the documentation on installing openCV,
so all you have to do now is to download the installation script from here and execute it.
don't forget to make it executable:
chmod +x opencv_latest.sh
then
./opencv_latest.sh
I installed opencv following the steps on https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html
Except on Step 2, use:
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/path/to/opencv/ ..
Then locate the opencv4.pc file, mine was in opencv/build/unix-install/
Now run:
$ export PKG_CONFIG_PATH=/path/to/the/file
Hi first of all i would like you to use 'Synaptic Package Manager'. You just need to goto the ubuntu software center and search for synaptic package manager.. The beauty of this is that all the packages you need are easily available here. Second it will automatically configures all your paths. Now install this then search for opencv packages over there if you found the package with the green box then its installed but else the package is not in the right place so you need to reinstall it but from package manager this time. If installed then you can do this only, you just need to fill the OpenCV_DIR variable with the path of opencv (containing the OpenCVConfig.cmake file)
export OpenCV_DIR=<path_of_opencv>
I got the same error when trying to compile a Go package on Debian 9.8:
# pkg-config --cflags -- libssl libcrypto
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
The thing is that pkg-config searches for package meta-information in .pc files. Such files come from the dev package. So, even though I had libssl installed, I still got the error. It was resolved by running:
sudo apt-get install libssl-dev
Writing this answer specially for MacOS users.
First to install opencv use:
brew install opencv
or brew install opencv#x (x = 2,4)
We need to have the path of opencv.pc in the PKG_CONFIG_PATH to avoid this error. When you install opencv with brew it says something like this on console
For pkg-config to find opencv#2 you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/opencv#2/lib/pkgconfig"
As the error suggest the reason is that opencv is not in the PKG_CONFIG_PATH variable. First check what is inside the variable using:
echo $PKG_CONFIG_PATH
To include the location of opencv.pc to the PKG_CONFIG_PATH use this
echo 'export PKG_CONFIG_PATH="/opt/homebrew/opt/opencv/lib/pkgconfig:$PKG_CONFIG_PATH"' >> ~/.zshrc
$ ./configure --enable-libopencv
ERROR: opencv not found using pkg-config
$ cat /usr/lib64/pkgconfig/opencv.pc
# Package Information for pkg-config
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.1.0
Libs: -L${exec_prefix}/lib64 -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
Libs.private: -L/usr/lib64 -lQt5Test -lQt5Concurrent -lQt5OpenGL -L/lib64 -lwebp -lpng -ltiff -ljasper -ljpeg -lImath -lIlmImf -lIex -lHalf -lIlmThread -lgdal -lgstvideo-1.0 -lgstapp-1.0 -lgstbase-1.0 -lgstriff-1.0 -lgstpbutils-1.0 -lgstreamer-1.0 -lucil -lunicap -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfontconfig -lfreetype -lglib-2.0 -ldc1394 -lv4l1 -lv4l2 -lgphoto2 -lgphoto2_port -lexif -lQt5Core -lQt5Gui -lQt5Widgets -lhdf5_hl -lhdf5 -lz -ldl -lm -ltesseract -llept -lpthread -lrt -lGLU -lGL
Cflags: -I${includedir_old} -I${includedir_new}
$ pkg-config --cflags --libs opencv
-I/usr/include/opencv -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
$ uname -a
Linux fedora-23-x64 4.8.13-100.fc23.x86_64 #1 SMP Fri Dec 9 14:51:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ apt-file search opencv.pc
$ ls /usr/local/lib/pkgconfig/
$ sudo cp /usr/local/lib/pkgconfig/opencv4.pc /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc
$ pkg-config --modversion opencv
Please try to set the environment in .bashrc:
tomapaxxx#localhost:~$ cat .bashrc
a)export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/workspace/usr/local/pkgconfig
export PYTHONPATH=/usr/bin/python2.7:$PYTHONPATH
b)After edition please find the file opencv.pc ,mkdir -p ~/workspace/usr/local/pkgconfig,then copy opencv.pc under the path ~/workspace/usr/local/pkgconfig.
d)source .bashrc under ~/. or ~/.bashrc.
eg: root#localhost:source ~/.bashrc
e)At the end you can use pkg-config --libs --cflags opencv to check whether you can see any information.
f)It is better if you can write information in .bash_profile with ./bashrc.
if [ -f ~/.bashrc ];
then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv/
mkdir build
cd build/
#now Run cmake
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
check detailed explanation here
https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html
From opencv 4.0:
add -DOPENCV_GENERATE_PKGCONFIG=YES to cmake build arguments.
Use YES, ON is not working anymore.
Example:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-DWITH_V4L=ON \
-DWITH_LIBV4L=ON \
-DWITH_FFMPEG=ON \
-DOPENCV_GENERATE_PKGCONFIG=YES \
-D BUILD_EXAMPLES=ON ..

Resources