Issues with OpenCV common pkg-config --cflags --libs opencv - opencv

I am trying to install openCV on my Mac, and have gotten to the point of calling this command:
pkg-config --cflags --libs opencv
and get the error:
Variable 'prefix not defined in '/usr/local/lib/pkgconfig/opencv.pc'
I've tried looking online and cannot find anything about this error. Any advice?

Related

Library not Found,library not found for -lopencv_calib3d.3.3

Ld build/Release-iphoneos/Demo.app/Demo normal arm64
cd /Users/meitu/Desktop/Demo3
export IPHONEO _ DEPLOYMENT _ TARGET=11.0
you have to install the debug version of OpenCV 3.3.
If you use cmake follow the instruction given by
https://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html
For integration into a makefile under linux you can use the useful commands
pkg-config --cflags opencv
pkg-config --libs opencv
in your Makefile.
Maybe you must compile openCV by yourself setting the debug option.

Compile error: libicui18n.so.54 needed by libQt5Core.so.5 not found

#include <opencv2/opencv.hpp> //头文件
using namespace cv; //包含cv命名空间
int main()
{
Mat img=imread("cornea.jpg");
imshow("src",img);
waitKey(0);
return 0;
}
And I compile it with:
g++ test.cpp -o test pkg-config opencv --cflags --libs opencv
Which gives me:
/usr/bin/ld: warning: libicui18n.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
/usr/bin/ld: warning: libicuuc.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
/usr/bin/ld: warning: libicudata.so.54, needed by //home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5, not found (try using -rpath or -rpath-link)<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_clone_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘uenum_next_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_strToLower_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getStandardName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_setAttribute_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_setMillis_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_strcoll_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_setSubstChars_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getTimeZoneDisplayName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openCountryTimeZones_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_fromUnicode_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getDefaultName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_inDaylightTime_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucol_getSortKey_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getAvailableName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_get_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openTimeZoneIDEnumeration_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getDSTSavings_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_open_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_openTimeZones_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_toUnicode_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_strToUpper_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘u_errorName_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘uenum_close_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_countAvailable_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getMaxCharSize_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_getAlias_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucal_getDefaultTimeZone_54’未定义的引用<br/>
//home/lmk/Qt5.5.0/5.5/gcc/lib/libQt5Core.so.5:对‘ucnv_compareNames_54’未定义的引用<br/>
collect2: error: ld returned 1 exit status
The backticks in command line pkg-config opencv --cflags --libs opencv is invisible. I have not got the reason now.
Indeed,in early days, I have installed Qt. But now, I do not want my program have something to do with Qt. In order that my program is not affected by the Qt library function, I shielded the path variables of Qt in the /etc/bash.bashrc file and installed a new gcc of 5.3.0. But the same error is still existing!
I'm using Ubuntu 14.04
Download ICU-54.1 from here
http://www.linuxfromscratch.org/blfs/view/7.7/general/icu.html
and install manually.
For me this solved the problem.

OpenCv Linking Issue

I'm using Kubuntu and have some Problems with linking OpenCv ( 2.4.6.1 ) Librarys ( I guess ).
So I've been using this tutorial http://karytech.blogspot.de/2012/05/opencv-24-on-ubuntu-1204.html and got the installation tested ok ( section: ./opencv_test_core ). Then I downloaded the testfile below but could make it work. Tried some other code always the same error:
g++ -L/usr/local/lib -lcv -lcxcore -lcvaux -lhighui -lm hello.cpp
/usr/bin/ld: cannot find -lcv
/usr/bin/ld: cannot find -lcxcore
/usr/bin/ld: cannot find -lcvaux
/usr/bin/ld: cannot find -lhighui
collect2: Fehler: ld gab 1 als Ende-Status zurück ( ld exit status is 1 )
( as for the strange library names in the tutorial i also tried -lopencv_calib3d ... )
then tried it in code::blocks and get this:
main.c undefined reference to cvGetRows
Headers are in /usr/local/include/opencv
/usr/local/include/opencv2
Librarys are in usr/local/lib
( If that helps ):
$ pkg-config --cflags opencv
returns: -I/usr/local/include/opencv -I/usr/local/include
$ pkg-config --libs opencv
returns: /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so ...
$ apt-cache search opencv
returns: opencv-doc - OpenCV documentation and examples
python-opencv - Python-Anbindungen für die OpenCV-Bibliothek
libavcodec-extra-53 - Libav codec library ...
To link against OpenCV, you have to pass g++ (which will run ld internally) where the libraries are (if they are not standard ones). You can do it manually, if you want to link only some of them.
But the fastest way is to rely on pkg-config:
g++ faceDetect.cpp $(pkg-config --libs opencv --cflags)
However, in the package there's a Makefile, just cd the directory you've extracted that archive, and run make.

pkg-config --cflags opencv: No such file or directory

I'm writing a basic example of opencv, but make command give me message
g++-4.7.real: error: pkg-config --cflags opencv: No such file or directory
g++-4.7.real: error: pkg-config --libs opencv: No such file or directory
issue command pkg-config --cflag opencv give me result as:
-I/usr/local/include/opencv -I/usr/local/include
and pkg-config --libs opencv give me:
-I/usr/local/include/opencv -I/usr/local/include
vudao#vudaopc:~/work/nmath/ntrainer$ pkg-config --libs opencv
/usr/local/lib/libopencv_contrib.a /usr/local/lib/libopencv_stitching.a /usr/local/lib/libopencv_nonfree.a /usr/local/lib/libopencv_superres.a /usr/local/lib/libopencv_ocl.a /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_videostab.a /usr/local/lib/libopencv_gpu.a /usr/local/lib/libopencv_photo.a /usr/local/lib/libopencv_objdetect.a /usr/local/lib/libopencv_legacy.a /usr/local/lib/libopencv_video.a /usr/local/lib/libopencv_ml.a /usr/local/lib/libopencv_calib3d.a /usr/local/lib/libopencv_features2d.a /usr/local/lib/libopencv_highgui.a /usr/local/share/OpenCV/3rdparty/lib/libIlmImf.a /usr/local/share/OpenCV/3rdparty/lib/liblibjasper.a /usr/local/share/OpenCV/3rdparty/lib/liblibtiff.a /usr/local/lib/libopencv_imgproc.a /usr/local/lib/libopencv_flann.a /usr/local/lib/libopencv_core.a /usr/lib/i386-linux-gnu/libbz2.so /usr/lib/i386-linux-gnu/libpng.so /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/i386-linux-gnu/libz.so -lswscale -lavformat -lavutil -lz -lSDL -lasound -lavcodec -lgthread-2.0 -lglib-2.0 -lgobject-2.0 -lfontconfig -lfreetype -lpango-1.0 -lcairo -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpangoft2-1.0 -lgio-2.0 -latk-1.0 -lgdk-x11-2.0 -lgtk-x11-2.0 -lrt -lpthread -lm -ldl -lstdc++
Below is my Makefile:
CC=g++
CFLAGS=-O2 -g 'pkg-config --cflags opencv'
LDFLAGS='pkg-config --libs opencv'
BIN=ntrainer
ntrainer : ntrainer.cpp
$(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) ntrainer.cpp
My system is Ubuntu 12.10. I have installed opencv-2.4.7 successfully (I think) following instructions here http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/
I also have configured and exported PKG_CONFIG_PATH into /etc/bash.bashrc, I'v also ran ldconfig
Please someone tell me what I'm missing? And how to correct it.
Thanks too much.
You used incorrect quotes. You should use ` instead of ':
CC=g++
CFLAGS=-O2 -g `pkg-config --cflags opencv`
LDFLAGS=`pkg-config --libs opencv`
For me, the file was there but the path was wrong:
I had to look for the opencv.pc file, make sure it is in the path for the pkgconfig program to find (i.e. in one of the pkgconfig folders) and then make sure the prefix path in there is right.
In my case it was wrong because it was not installed via make install but i made a make package package because it was cross-compiled, and the path I had installed it at didn't match the CMAKE path.
running
pkg-config --cflags opencv
or
pkg-config --libs opencv
tells you where it is looking for the files, so you can make sure they match.

How to compile youtube-api application

I am developing a custom Youtube video player. But I am not able to compile the program. I am missing something in Makefile. My program looks like
main.c
#include<gdata/services/youtube/gdata-youtube-service.h>
int main(int argc, char **argv[])
{
printf("Youtube Application\n");
return 0;
}
makefile
gcc `pkg-config --cflags --libs libgdata-google-1.2`  -lgdata-google-1.2 main.c -o youtube
When I compile, it is giving error like
error: gdata/services/youtube/gdata-youtube-service.h: No such file or directory
Do I got to install some other packages ? Or, i need to include something in my Makefile ?
Are you on Debian/Ubuntu? You probably want the libgdata-dev package.
$ apt-file search gdata/services/youtube/gdata-youtube-service.h
libgdata-dev: /usr/include/libgdata/gdata/services/youtube/gdata-youtube-service.h
Tried compiling it too, and tried using one of the methods declared in gdata-youtube-service.h
$ gcc `pkg-config --cflags --libs libgdata` main.c -o yt
$ ./yt
Youtube Application

Resources