Cant get OpenCV Version 4 to be compiled with my app.
-
wrote on 27 Apr 2020, 16:35 last edited by
Hi there,
I have problems using opencv4 on mac os x.
Any help and hints are welcome.
Thx in advance!
AlexanderI have used two different ways of installation for opencv4:
- I tried using Macports with this in my .pro file:
CONFIG += link_pkgconfig PKGCONFIG += opencv4 INCLUDEPATH += /opt/local/include LIBS += `pkg-config --cflags --libs`
The error i get is this:
Project ERROR: opencv4 development package not found
18:17:05: The process "/Applications/Qt/5.12.6/clang_64/bin/qmake" exited with code 3.
Error while building/deploying project spectraproof2 (kit: Desktop Qt 5.12.6 clang 64bit)- I compiled and installed it to /usr/local ... from source.
Because this does not provide opencv4.pc (pkg-config file) i set options in .pro file manually:
INCLUDEPATH += /usr/local/include LIBS += -L/usr/local/lib \ -lopencv_core \ -lopencv_highgui
The error i get is this:
Undefined symbols for architecture x86_64:
"cv::namedWindow(cv::String const&, int)", referenced from:
MainWindow::onImageUpdateNeeded() in mainwindow.o
"cv::String::deallocate()", referenced from:
cv::String::~String() in main.o
cv::String::operator=(cv::String const&) in main.o
cv::String::~String() in mainwindow.o
cv::String::operator=(cv::String const&) in mainwindow.o
cv::String::~String() in moc_mainwindow.o
cv::String::operator=(cv::String const&) in moc_mainwindow.o
"cv::String::allocate(unsigned long)", referenced from:
cv::String::String(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mainwindow.o
cv::String::String(char const*) in mainwindow.o
"cv::imread(cv::String const&, int)", referenced from:
MainWindow::on_actionOpenImage_triggered() in mainwindow.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
MainWindow::onImageUpdateNeeded() in mainwindow.o
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
MainWindow::on_actionSaveImage_triggered() in mainwindow.o
"cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
MainWindow::processImage(cv::Mat const&, cv::Mat&) in mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SpectraProof.app/Contents/MacOS/SpectraProof] Error 1
18:29:51: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project spectraproof2 (kit: Desktop Qt 5.12.6 clang 64bit) -
That file is generated as part of building / installing the library.
It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.
wrote on 30 Apr 2020, 10:37 last edited by ademmlerAs I said opencv community has dropped png-config support.
Hence I needed to recompile with opencv4.pc file.
This one needed manual fixing of th path ...
Now it works - for me at least. thx for your helpAnother - even easier solution is to configure *.pro by hand:
unix: macx{
DEPENDPATH += /usr/local/lib
INCLUDEPATH += /usr/local/include/opencv4
+= /usr/local/include/opencv4/opencv2
LIBS += -L/usr/local/lib
-lopencv_calib3d
-lopencv_core
-lopencv_dnn
-lopencv_features2d
-lopencv_flann
-lopencv_gapi
-lopencv_highgui
-lopencv_imgcodecs
-lopencv_imgproc
-lopencv_ml
-lopencv_objdetect
-lopencv_photo
-lopencv_stitching
-lopencv_video
-lopencv_videoio
} -
Hi,
Where is the opencv4.pc file located on your system ?
-
wrote on 29 Apr 2020, 07:29 last edited by
Hi, thx for responding.
opencv4 does not provide opencv4.pc
If you use self compiled packages it should be in /usr/local/lib/pkg-config.
If you use Macports it should be in /opt/local/lib/pkg-configOutput from png-config:
-I/opt/local/include/opencv4/opencv -I/opt/local/include/opencv4 -L/opt/local/lib -lopencv_dnn -lopencv_gapi -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -
That file is generated as part of building / installing the library.
It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.
-
That file is generated as part of building / installing the library.
It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.
wrote on 30 Apr 2020, 10:37 last edited by ademmlerAs I said opencv community has dropped png-config support.
Hence I needed to recompile with opencv4.pc file.
This one needed manual fixing of th path ...
Now it works - for me at least. thx for your helpAnother - even easier solution is to configure *.pro by hand:
unix: macx{
DEPENDPATH += /usr/local/lib
INCLUDEPATH += /usr/local/include/opencv4
+= /usr/local/include/opencv4/opencv2
LIBS += -L/usr/local/lib
-lopencv_calib3d
-lopencv_core
-lopencv_dnn
-lopencv_features2d
-lopencv_flann
-lopencv_gapi
-lopencv_highgui
-lopencv_imgcodecs
-lopencv_imgproc
-lopencv_ml
-lopencv_objdetect
-lopencv_photo
-lopencv_stitching
-lopencv_video
-lopencv_videoio
}
1/5