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

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.

Related

Building FFmpeg for use in Swift

With the new XCode/Swift release comes the ability to use binary dependencies. This seems to me to be an ideal time to create an SPM package for FFMpeg.
However, while I've spent the last year learning to code i Swift, I'm actually not all that familiar with how to build libraries, especially those as complex as FFmpeg with all the configurable libraries and third-party dependencies.
There's kewlbear's iOS build scripts, but these are for iOS/tvOS and ideally an FFMpeg SPM package would be usable for MacOS also. It's also not updated for the newest Xcode and Swift versions.
My personal interest is simply in audio and I don't need a lot of bells and whistles, but I figure the ideal situation would be a full package with the entire source and whatever dependencies it needs, and then when it's used as a package dependency, the compiler will just use the parts it needs.
I guess my question is...how would I ideally compile the ffmpeg code for this purpose. I'm trying to follow the directions for compiling yourself, but I'm stuck at the point of compiling gettext because I'm not sure if I should follow the directions (in the gettext source code) for compiling a fat binary for multiple architectures, and when I try to run:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
I get the following error:
checking whether the C compiler works... no configure: error: in
`/Users/nolainecrusher/Downloads/FFMpeg-source/gettext-0.21/gettext-runtime':
configure: error: C compiler cannot create executables See
`config.log' for more details configure: error: ./configure failed for
gettext-runtime
and config.log doesn't really tell me anything useful:
This is what I see at the end of the log:
mkdir_p='$(MKDIR_P)' oldincludedir='/usr/include' pdfdir='${docdir}'
prefix='/usr/local' program_transform_name='s,x,x,' psdir='${docdir}'
sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com' subdirs='
gettext-runtime libtextstyle gettext-tools' sysconfdir='${prefix}/etc'
target_alias=''
I feel like maybe I'm going about this the wrong way, but I'm not sure what the right way is.
See the following:
A Swift wrapper package for FFmpeg and
A C wrapper package for FFmpeg
SwiftFFmpeg assumes ffmpeg is installed locally and will link with those libraries. Also, SwiftFFmpeg uses CFFmpeg as a package dependency, and your app can use SwiftFFmpeg as a dependency.
If you want to see a build script for compiling ffmpeg (x86_64 and arm64), check out my own audio player project.

Issues with OpenCV common pkg-config --cflags --libs 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?

How to set the include path, #include "opencv2/opencv.hpp"

I am trying to do Compiling With OpenCV section in this page: Installing Darknet
After I did OPENCV = 1, I tried to do re-make, so I did make in the darknet directory.
The directory is below.
(yolo) bash-3.2$ pwd
/Users/moray/darknet
(yolo) bash-3.2$ ls
LICENSE LICENSE.gpl LICENSE.v1 backup data libdarknet.a python src
LICENSE.fuck LICENSE.meta Makefile cfg examples libdarknet.so results
LICENSE.gen LICENSE.mit README.md darknet include obj scripts
and the result of the re-makaing is here.
(yolo) bash-3.2$ make
g++ -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv` -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -c ./src/image_opencv.cpp -o obj/image_opencv.o
/bin/sh: pkg-config: command not found
./src/image_opencv.cpp:6:10: fatal error: 'opencv2/opencv.hpp' file not found
#include "opencv2/opencv.hpp"
^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [obj/image_opencv.o] Error 1
So I thought include path could not reference opencv.hpp, I looked for the file and found it.
(yolo) bash-3.2$ ls ~/opt/anaconda3/pkgs/libopencv-3.4.2-h7c891bd_1/include/opencv2/opencv.hpp
/Users/moray/opt/anaconda3/pkgs/libopencv-3.4.2-h7c891bd_1/include/opencv2/opencv.hpp
Therefore I tried to change #include "opencv2/opencv.hpp" to "include "~/opt/anaconda3/pkgs/libopencv-3.4.2-h7c891bd_1/include/opencv2/opencv.hpp" in ./src/image_opencv.cpp
And the result is here.
(yolo) bash-3.2$ make
g++ -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv` -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -c ./src/image_opencv.cpp -o obj/image_opencv.o
/bin/sh: pkg-config: command not found
./src/image_opencv.cpp:7:10: fatal error:
'~/opt/anaconda3/pkgs/libopencv-3.4.2-h7c891bd_1/include/opencv2/opencv.hpp' file not found
#include "~/opt/anaconda3/pkgs/libopencv-3.4.2-h7c891bd_1/include/opencv2/opencv.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [obj/image_opencv.o] Error 1
I cannot understand why the error happens.
Please tell me your think.
============================================
os: macOS Catalina 10.15.1
(yolo) is a virtual environment in anaconda(3)
opencv was installed by pip command in (yolo)
all the packages by pip command in (yolo):
(yolo) bash-3.2$ pip list
Package Version
--------------------- -------------------
certifi 2019.11.28
numpy 1.17.4
opencv-contrib-python 4.1.2.30
opencv-python 4.1.1.26
pip 19.3.1
setuptools 42.0.2.post20191203
wheel 0.33.6
gcc:
(yolo) bash-3.2$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
This error explains it pkg-config: command not found. In order to use OpenCV in YOLO, you have to install OpenCV that works for C or C++ program, not Python. You probably installed opencv using pip for Python. Follow these steps in one of these links to install opencv : this or this or other tutorial.
After that, to check whether you have installed OpenCV correctly and can be used in C program, run this command :
pkg-config --modversion opencv
If it doesn't show anything or shows wrong version, try to reinstall OpenCV OR it is possible that your machine doesn't locate opencv version correctly.
So add command to your ~/.bashrc for example :
vim ~/.bashrc
export PKG_CONFIG_PATH=/home/user/installation/OpenCV-3.4.0/lib/pkgconfig
source ~/.bashrc
Notes : Change the path according to your opencv installation directory that contains opencv.pc

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.

Strange linker error while compiling OpenCV2.3.1 on Ubuntu 11.10

I'm trying to compile OpenCV version 2.3.1 on an Ubuntu 11.10 following instructions described here. I'm getting following error. Can't understand what is happening... /usr/local/lib/libavcodec.a exists but linker can't link against it, or something else?
error:
[ 20%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet'
can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
The problem is that you are attempting to link libopencv_highgui.so with libavcodec.a. The latter is built from code compiled without -fPIC (which is quite usual), and such code can not be linked into shared libraries on x86_64.
Your choices are:
Obtain libavcodec.so and arrange to link against it, or
Remove libavcodec or -lavcodec from the link line completely.
For the first, you most likely just need to install libavcodec-dev package.
If you do the second, you will still have to arrange for symbols that libopencv_highgui.so needs from libavcodec to be available at runtime. You can achieve that by linking the main executable with libavcodec (either archive or shared variant).
my take would be that, first run sudo apt-get remove libavcodec , then re-install with sudo apt-get install libopencv-dev
I once had similar issue, and the above resolved it
Running a 64-bit version of Ubuntu you have to configure and build ffmpeg with
./configure --enable-shared --enable-pic
as it is described in step 7b and 8b

Resources