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

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 ..

Related

Docker failed with [Makefile:192: imagick_file.lo] Error 127

I try to install php in docker of w2orking project with header in Dockerfile :
FROM composer:1 AS composer
FROM php:7.4-fpm-alpine
COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV PHPIZE_DEPS \
build-base \
...
I got errors:
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserOFhDoe/imagick-3.4.3/libtool --mode=compile cc -I/usr/include/ImageMagick-7 -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I. -I/tmp/pear/temp/imagick -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserOFhDoe/imagick-3.4.3/include -I/tmp/pear/temp/pear-build-defaultuserOFhDoe/imagick-3.4.3/main -I/tmp/pear/temp/imagick -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/include/ImageMagick-7 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/imagick/imagick_file.c -o imagick_file.lo
make: /bin/sh: Operation not permitted
make: *** [Makefile:192: imagick_file.lo] Error 127
ERROR: `make' failed
ERROR: Service 'backapp' failed to build: The command '/bin/sh -c set -xe && apk add --no-cache ${PERMANENT_DEPS} && apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} && apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community gnu-libiconv && pecl install imagick-3.4.3 && docker-php-ext-enable imagick && docker-php-ext-configure pdo_mysql && docker-php-ext-configure bcmath --enable-bcmath && docker-php-ext-configure pcntl --enable-pcntl && docker-php-ext-configure intl --enable-intl && docker-php-ext-configure sysvmsg && docker-php-ext-configure sysvsem && docker-php-ext-configure sysvshm && docker-php-ext-install -j$(nproc) pdo_mysql sockets gettext bcmath pcntl intl sysvmsg sysvsem sysvshm && apk del .build-deps' returned a non-zero code: 1
Searching in net for decision I check cc/gcc in my system :
ProjectName$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
ProjectName$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
ProjectName$ uname -a
Linux master-laptop 5.11.0-37-generic #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
ProjectName$ composer -v
______
Composer version 2.1.8 2021-09-15 13:55:14
Also I installed build-essential, but checking its info I found error in its output. Could it be the issue, but how to fix bit ?
$ apt show build-essential — info -a
Package: build-essential
Version: 12.8ubuntu1.1
Priority: optional
Build-Essential: yes
Section: devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko#debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 21,5 kB
Depends: libc6-dev | libc-dev, gcc (>= 4:9.2), g++ (>= 4:9.2), make, dpkg-dev (>= 1.17.11)
Task: ubuntu-mate-core, ubuntu-mate-desktop
Download-Size: 4 664 B
APT-Manual-Installed: yes
APT-Sources: http://ua.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: Informational list of build-essential packages
If you do not plan to build Debian packages, you don't need this
package. Starting with dpkg (>= 1.14.18) this package is required
for building Debian packages.
.
This package contains an informational list of packages which are
considered essential for building Debian packages. This package also
depends on the packages on that list, to make it easy to have the
build-essential packages installed.
.
If you have this package installed, you only need to install whatever
a package specifies as its build-time dependencies to build the
package. Conversely, if you are determining what your package needs
to build-depend on, you can always leave out the packages this
package depends on.
.
This package is NOT the definition of what packages are
build-essential; the real definition is in the Debian Policy Manual.
This package contains merely an informational list, which is all
most people need. However, if this package and the manual disagree,
the manual is correct.
Package: build-essential
Version: 12.8ubuntu1
Priority: optional
Build-Essential: yes
Section: devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko#debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 20,5 kB
Depends: libc6-dev | libc-dev, gcc (>= 4:9.2), g++ (>= 4:9.2), make, dpkg-dev (>= 1.17.11)
Task: ubuntu-mate-core, ubuntu-mate-desktop
Download-Size: 4 624 B
APT-Sources: http://ua.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: Informational list of build-essential packages
If you do not plan to build Debian packages, you don't need this
package. Starting with dpkg (>= 1.14.18) this package is required
for building Debian packages.
.
This package contains an informational list of packages which are
considered essential for building Debian packages. This package also
depends on the packages on that list, to make it easy to have the
build-essential packages installed.
.
If you have this package installed, you only need to install whatever
a package specifies as its build-time dependencies to build the
package. Conversely, if you are determining what your package needs
to build-depend on, you can always leave out the packages this
package depends on.
.
This package is NOT the definition of what packages are
build-essential; the real definition is in the Debian Policy Manual.
This package contains merely an informational list, which is all
most people need. However, if this package and the manual disagree,
the manual is correct.
Package: info
Version: 6.7.0.dfsg.2-5
Priority: standard
Section: doc
Source: texinfo
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Debian TeX maintainers <debian-tex-maint#lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 831 kB
Provides: info-browser
Depends: libc6 (>= 2.15), libtinfo6 (>= 6), install-info
Breaks: texinfo-doc-nonfree
Replaces: texinfo (<< 4.7-2), texinfo-doc-nonfree
Homepage: https://www.gnu.org/software/texinfo/
Task: standard
Download-Size: 203 kB
APT-Manual-Installed: no
APT-Sources: http://ua.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: Standalone GNU Info documentation browser
The Info file format is an easily-parsable representation for online
documents. This program allows you to view Info documents, like the
ones stored in /usr/share/info.
.
Much of the software in Debian comes with its online documentation in
the form of Info files, so it is most likely you will want to install it.
N: Unable to locate package —
How to fix this error ?
Modified BLOCK # 1:
Searching in net I found hints that reason of this error can be that some apps are not in $PATH
So I added line with build-essential path :
export PATH="/usr/share/build-essential:$PATH"
in file /home/master/.bashrc and run update command :
source ~/.bashrc
After that I check that all related apops in PATH :
master#master-laptop:ProjectName$ $PATH
bash: /usr/share/build-essential:/home/master/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
master#master-laptop:ProjectName$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/share/gcc /usr/share/man/man1/gcc.1.gz
master#master-laptop:ProjectName$ whereis cc
cc: /usr/bin/cc /usr/share/man/man1/cc.1.gz
master#master-laptop:ProjectName$ whereis build-essential
build-essential: /usr/share/build-essential
But anyway I got the same error :
...
make: /bin/sh: Operation not permitted
make: *** [Makefile:192: imagick_file.lo] Error 127
Thanks!
It's difficult to provide an accurate answer without the whole Dockerfile, but I will try to point your problem.
Well, first of all you're using a multi-staged build, but you're not taking advantage from it. The whole point about the composer image isn't just the Composer PHAR, but that image already contains all the dependencies require to build your PHP dependencies.
Meanwhile you have something like this:
FROM composer:1 as composer
FROM php:7.4-fpm-alpine
ENV ...
[BUILD_PROCESS]
[EXTRA_PROCESS]
You should have something like this:
FROM composer:1 as vendor
WORKDIR /app
COPY database/ database/
COPY composer.json composer.json
COPY composer.lock composer.lock
[BUILD_PROCESS]
FROM php:7.4-fpm-alpine
WORKDIR /app
COPY --from=vendor /app/vendor/ ./vendor/
COPY . .
[EXTRA_PROCESS]
Basically: delegate the build of the dependencies to the Composer image and use your lightweight PHP Alpine just for the application.
Using multiple FROM clauses creates multiple images
I agree with #Daniel Campos however I will suggest looking at the resultant images. You should file multiple.
Have a look at this thread which explains some more details.
Multiple FROMs - what it means

brew: unable to install mumps on mac

I am trying to install ipopt by:
brew install ipopt.rb --with-openblas
and I got the following error:
==> Installing dependencies for ipopt: mumps
==> Installing ipopt dependency: mumps
==> Downloading http://mumps.enseeiht.fr/MUMPS_5.1.1.tar.gz
Already downloaded: /Users/yufeiliu/Library/Caches/Homebrew/mumps-5.1.1.tar.gz
==> make alllib LIBEXT=.dylib AR= -dynamiclib -Wl,-install_name -Wl,/usr/local/Cellar/mumps/5.1.
Last 15 lines from /Users/yufeiliu/Library/Logs/Homebrew/mumps/01.make:
clang -fPIC -I../include -O -c symbfac.c -o symbfac.o
clang -fPIC -I../include -O -c interface.c -o interface.o
clang -fPIC -I../include -O -c sort.c -o sort.o
clang -fPIC -I../include -O -c minpriority.c -o minpriority.o
dynamiclib -Wl,-install_name -Wl,/usr/local/Cellar/mumps/5.1.1_1/lib/libpord.dylib -undefined dynamic_lookup -o libpord.dylib graph.o gbipart.o gbisect.o ddcreate.o ddbisect.o nestdiss.o multisector.o gelim.o bucket.o tree.o symbfac.o interface.o sort.o minpriority.o
make[2]: dynamiclib: No such file or directory
make[2]: [libpord.dylib] Error 1 (ignored)
echo libpord.dylib
libpord.dylib
if [ "./PORD/lib/" != "" ] ; then \
cp ./PORD/lib//libpord.dylib lib/libpord.dylib; \
fi;
cp: ./PORD/lib//libpord.dylib: No such file or directory
make[1]: *** [lib/libpord.dylib] Error 1
make: *** [c] Error 2
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/brewsci/homebrew-science/issues
Does anyone know how to solve this?
Unfortunately installation of mumps package with brew is very problematic at this moment. You have two different ways to install mumps
Method 1:
brew tap brewsci/science
brew install mumps
if that didn't work, download mumps.rb from here
brew install ./mumps.rb
Method 2
brew tap dpo/openblas
brew install mumps
The second method might lead to some issues with scalapack later.
Update: Unfortunately the above method might not work properly anymore. I have updated the installation method here.

Linking OpenCV with cmake . Adding the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH doesn't work

I am trying to create the script to compile and run as mentioned by emscirpten.
This is the command I wish to create a cmake file for.
./emcc -std=c++11 -O3 -I.. ~/DLIB/dlib-19.4/dlib/all/source.cpp -I/home/akshay/DLIB/dlib-19.4 -I/usr/include/X11/ -lpthread -lX11 -lopencv_imgcodecs -o webca.js ~/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp -ldlib `pkg-config opencv --cflags --libs`
So far I have come up with this. This is my CMAKELists.txt file.
cmake_minimum_required(VERSION 3.5.1)
project(DLIB)
SET(CMAKE_BUILD_TYPE_INIT "Release")
set(CMAKE_CXX_STANDARD 11)
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(CMAKE_C_COMPILER "emcc")
endif ()
if(NOT DEFINED OpenCV_PREFIX)
set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build.emscripten)
set(DLIB_SRC "/home/akshay/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp")
add_library(DLIB_static ${DLIB_SRC})
set(OpenCV_PREFIX /usr/share/OpenCV/OpenCVConfig.cmake)
include_directories(/usr/include/X11 /home/akshay/DLIB/dlib-19.4 /home/akshay/DLIB/dlib-19.4/dlib/all/source.cpp)
set_target_properties(DLIB_static PROPERTIES LINK_FLAGS "-s DEMANGLE_SUPPORT=1 --preload-file assets --bind")
find_package(PkgConfig REQUIRED)
find_package(OpenCV REQUIRED
PATHS ${OpenCV_PREFIX}/lib/cmake/
${OpenCV_PREFIX}/share/OpenCV/
NO_DEFAULT_PATH)
find_library(OpenCV REQUIRED PATHS ${OpenCV_PREFIX}/lib/cmake/
${OpenCV_PREFIX}/share/OpenCV/
NO_DEFAULT_PATH)
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -O3 -lpthread -lX11 -lopencv_imgcodecs -ldlib `pkg-config opencv --cflags --libs`")
#file(GLOB_RECURSE CORE_HDR src/.h)
#file(GLOB_RECURSE CORE_SRC src/.cpp)
add_definitions("-s DEMANGLE_SUPPORT=1 --preload-file ${CMAKE_SOURCE_DIR}/assets --bind")
add_executable(DLIB /home/akshay/DLIB/dlib-19.4/examples/webcam_face_pose_ex.cpp)
When I run this command :cmake -DCMAKE_PREFIX_PATH=/usr/share/OpenCV/OpenCVConfig.cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/akshay/Downloads/emsdk-portable/emscripten/1.37.16/cmake/Modules/Platform/Emscripten.cmake . && make
It gives me an error like so :
CMake Error at CMakeLists.txt:25 (find_package):
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
It seems to not be able to find the CMAKE_PREFIX_PATH or that I am not setting it correctly.
I have just started fiddling around with CMAKE since yesterday. I may have very little clue about what I have done. Have tried some of the other SO answers as well.
Any help will be appreciated
You simply need to set the OpenCV_DIR to the path where OpenCV is installed, for example:
cmake -DOpenCV_DIR=/usr/local/share/OpenCV ..

How to get a smaller toolchain from scratch?

I have built a custom toolchain from scratch for a MIPS 24kc (dragino) target platform, using gcc-6.3.0, musl-1.1.16 and binutils-2.27. That toolchain is completely functional.
However, the size of my-custom toolchain is five times bigger than size of equivalent OpenWRT generated toolchain (557M vs 113M). Toolchain binaries generated by OpenWRT (mips-openwrt-linux-musl-*) are dynamically linked against libstdc++ and libgcc_s libraries. However, my toolchain binaries are linked with these libs statically:
$ ldd mips-openwrt-linux-musl-gcc-5.3.0
linux-vdso.so.1 => (0x00007ffc4d534000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f878936f000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8789159000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8788d8f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8788a86000)
/lib64/ld-linux-x86-64.so.2 (0x000055df3ef8b000)
$ ldd mips-linux-musl-gcc-6.3.0
linux-vdso.so.1 => (0x00007ffd40940000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2de4b8f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2de47c6000)
/lib64/ld-linux-x86-64.so.2 (0x0000560bba4b6000)
The same linking issue happens with cc1 and cc1plus. Sizes of these two binaries are huge (cc1 is 124MB, cc1plus is 134MB).
My question is: what is the proper way to setup the cross-toolchain generation to get a cross-platform toolchain as small as the OpenWRT generated toolchain?
Bellow you can find the steps I'm doing to build my-custom toolchain for reference:
Download sources:
wget http://ftpmirror.gnu.org/binutils/binutils-2.27.tar.bz2
wget http://ftpmirror.gnu.org/gcc/gcc-6.3.0/gcc-6.3.0.tar.bz2
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.12.6.tar.bz2
wget https://www.musl-libc.org/releases/musl-1.1.16.tar.gz
wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.5.tar.bz2
wget http://ftpmirror.gnu.org/gmp/gmp-6.1.2.tar.bz2
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz
Setup build environment:
export ROOTDIR="${HOME}/custom-toolchains/MIPS"
export NATIVE_PREFIX="${ROOTDIR}/opt/native"
export CROSS_PREFIX="${ROOTDIR}/opt/cross"
export TARGET_MACHINE=mips
export CPU=mips
export ARCH=24kc
export CLIB=musl
export TARGET_TRIPLET=${CPU}-linux-${CLIB}
Build native binutils:
cd ${ROOTDIR}/src
mkdir build-binutils
cd build-binutils
../binutils-2.27/configure --prefix="${NATIVE_PREFIX}" --disable-nls --disable-werror --disable-multilib
make
make install
Build native gcc:
cd ${ROOTDIR}/src/gcc-6.3.0
ln -s ../mpfr-3.1.5 mpfr
ln -s ../gmp-6.1.2 gmp
ln -s ../mpc-1.0.3 mpc
cd ..
mkdir build-gcc
cd build-gcc
../gcc-6.3.0/configure --prefix=${NATIVE_PREFIX} --disable-nls --enable-languages=c --disable-multilib
make
make install
Build cross-binutils:
cd ${ROOTDIR}/src
mkdir build-${CPU}-binutils
cd build-${CPU}-binutils
../binutils-2.27/configure --target=${TARGET_TRIPLET} --prefix=${CROSS_PREFIX} --with-sysroot --disable-nls --disable-werror --disable-multilib
make
make install
Install kernel headers:
cd ${ROOTDIR}/src
cd linux-3.12.6
make ARCH=${TARGET_MACHINE} INSTALL_HDR_PATH=${CROSS_PREFIX}/${TARGET_TRIPLET} headers_install
Build cross-gcc (stage 1)
cd ${ROOTDIR}/src
mkdir build-bootstrap-${CPU}-gcc
cd build-bootstrap-${CPU}-gcc
../gcc-6.3.0/configure --target=${TARGET_TRIPLET} --prefix=${CROSS_PREFIX} --disable-nls --enable-languages=c --disable-multilib --disable-threads --disable-shared --with-float=soft --with-arch=${ARCH}
make all-gcc install-gcc
make all-target-libgcc install-target-libgcc
Build cross-musl
cd ${ROOTDIR}/src
mkdir build-${CLIB}
cd build-${CLIB}
CC=${TARGET_TRIPLET}-gcc CFLAGS=-Wa,-msoft-float ../musl-1.1.16/configure --prefix=${CROSS_PREFIX}/${TARGET_TRIPLET}/ --enable-optimize CROSS_COMPILE=${TARGET_TRIPLET}-
make
make install
Build cross-gcc (stage 2)
cd ${ROOTDIR}/src
mkdir build-${CPU}-gcc
cd build-${CPU}-gcc
../gcc-6.3.0/configure --target=${TARGET_TRIPLET} --prefix=${CROSS_PREFIX} --disable-nls --enable-languages=c,c++ --disable-multilib --enable-threads --enable-shared --with-float=soft --with-arch=${ARCH} --enable-target-optspace --disable-libgomp --disable-libmudflap --without-isl --without-cloog --disable-decimal-float --disable-libssp --disable-libsanitizer --enable-lto --with-host-libstdcxx=-lstdc++
make
make install
Thank you for all your comments in advance!
Fixing this issue has been simpler than expected... All toolchain binaries are installed non-stripped. So this can be fixed calling
$ make install-strip
instead of
$ make install
when you install cross-gcc (stage 2).
Size of generated toolchain is 122MB, what is nice compared with 557M of the original toolchain. So this issue is fixed! Hope this information will be useful for somebody else in the future. Thank you!

Cross compiling fontconfig for 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.

Resources