OpenCV 2.4.6 with QT 5.1.0 Errors - qt

I am trying to get OpenCv2.4.6 to work with QT5.1.0
I've followed this Guide so far Qt creator 5.0.1 with OpenCv 2.3.4 on windows
Unfortunatly after finishing trying out the sample Application(Display an Image using OpenCv in the QtCreator I get these Errors:
[Project-Path]\main.o:-1: In function `main':
[Project-Path]\main.cpp:8: error: undefined reference to `cv::imread(std::string const&, int)'
[Project-Path]\main.cpp:9: error: undefined reference to `cv::namedWindow(std::string const&, int)'
[Project-Path]\main.cpp:10: error: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
[Project-Path]\main.cpp:10: error: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
[Project-Path]\main.cpp:11: error: undefined reference to `cv::waitKey(int)'
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3MatD1Ev':
[OpenCV/Install/include]\opencv2\core\mat.hpp:278: error: undefined reference to `cv::fastFree(void*)'
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3Mat7releaseEv':
[OpenCV/Install/include]\opencv2\core\mat.hpp:367: error: undefined reference to `cv::Mat::deallocate()'
collect2.exe:-1: error: error: ld returned 1 exit status
the "[]" Paths are my formatting and supposed to help keep track .
main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main() {
// read an image
Mat image = imread("img.jpg");
namedWindow("My Image");
imshow("My Image", image);
waitKey(5000);
return 1;
}
myFirstOpenCVProject.pro
QT += core
QT -= gui
TARGET = myFirstOpenCVProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:/qt/OpenCV246_bin/install/include
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_core246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_highgui246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_imgproc246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_features2d246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_calib3d246.dll
Can you help me resolve this?
I can't find any solutions that apply to my case ...

-L is to add directories to the search path. The actual libs are added via -l. The correct line would be:
LIBS += -LC:/qt/OpenCV246_bin/install/lib -llopencv_core246 -llopencv_highgui246 ...

I think you are missing the static libs of opencv:
opencv_core246.lib
opencv_highgui246.lib
opencv_video246.lib
opencv_ml26d.lib
opencv_legacy246.lib
opencv_imgproc246.lib
opencv_whatever.lib
Don t know the pro commands very well. Maybe something like:
LIBS += -Lc:/blabla/opencv_imgproc246.lib

Related

build openCV & Qt project and link error:undefined reference and bad reloc address 0x1 in section

I have built the release version of openCV 4.5.1 shared library with CMake 3.91.2 & MinGW-W64 GCC-6.4.0 i686-posix-dwarf with default compile config.
Tried to use the libraries with Qt 5.4 & MinGW 4.9.1 32 bit.
I'm in Windows 10 64 bit.
Here's my .pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test05
TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += $$PWD/include
LIBS += -L$$PWD/lib/opencv -lopencv_highgui451.dll -lopencv_core451.dll -lopencv_imgcodecs451.dll -lopencv_imgproc451.dll
Here's main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
Mat image = imread("D:\\test.jpg");
namedWindow("window", WINDOW_AUTOSIZE );
imshow("window",image);
waitKey(0);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Here's build output:
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::imread(std::string const&, int)'
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::namedWindow(std::string const&, int)'
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
:-1: error: release/main.o: bad reloc address 0x1 in section `.text$_ZN7cvflann7anyimpl21typed_base_any_policyIbE4typeEv[__ZN7cvflann7anyimpl21typed_base_any_policyIbE4typeEv]'
collect2.exe:-1: error: error: ld returned 1 exit status
I have googled a lot,these two questions seems close to my situation but could not solve my problem:
Undefined reference to cv::imread(std::string const&, int)
C++ Qt MingW bad reloc 0xc address in section rdata
EDIT:
Thank for your advice,I deleted the GUI part and tried these:
LIBS += E:\workspace\test05\lib\opencv\libopencv_core451.dll.a
LIBS += E:\workspace\test05\lib\opencv\libopencv_core451.dll
Both don't work,the issues keep the same as above.I don't know if I built the shared library correctly or it's a simple link error?

Programm crashes using Taglib

I am trying to use Taglib with Qt5.7. But my programm crashes:
The GDB process terminated unexpectedly (exit code 0).
Cannot continue debugged process: The program is not being run.
During startup program exited with code 0xc0000135
There did not seem to be any error messages while building Taglib.
*.pro file
QT += core
QT -= gui
CONFIG += c++11
TARGET = untitled2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
TAGLIBDIR = $$quote(D:/D/Programmieren/Libraries/taglib)
INCLUDEPATH += $$quote( $${TAGLIBDIR}/include )
LIBS += -L$$quote($${TAGLIBDIR}/lib) -ltag
main.cpp
#include <QCoreApplication>
#include <taglib/tag.h>
#include <taglib/fileref.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TagLib::FileRef ref("D:/D/Media/Musik/Disturbed/The Sickness/Disturbed - Stupify.mp3");
return a.exec();
}
Edit:
I created Taglib-buildfiles using CMake-GUI and native MinGW-Installation since I did not manage to create them using Qt. My OS is Windows 10 x64 Education and I use Qt-Creator. I downloaded the latest Taglib-Release (1.11.1)
Why I cant create buildfiles using CMake:
First some *dll-files where missing, i coud solve that by just copying the ones from native MinGW-Installation to QT-MinGW.
Second I could not find any of the *exe-files desired by CMake so i could not change the path from native MinGW-Installation.
After rebuilding Taglib in debugmode I get this errors:
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
main.cpp:11: error: undefined reference to `_imp___ZNK6TagLib7FileRef3tagEv'
main.cpp:11: error: undefined reference to `_imp___ZNK6TagLib6String9toCStringEb'
main.cpp:11: error: undefined reference to `_imp___ZN6TagLib6StringD1Ev'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
main.cpp:11: error: undefined reference to `_imp___ZN6TagLib6StringD1Ev'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
collect2.exe:-1: error: error: ld returned 1 exit status
Solved it by using new version (5.8 instead of 5.7) of Qt.

Qt + GDCM problems with the libs

I'm trying to use the library gdcm in my project. However I'm with some problem.
gdcmGlobal.cxx:-1: error: undefined reference to gdcm::System::FileIsDirectory(char const*)'
gdcmGlobal.cxx:-1: error: undefined reference togdcm::System::FileIsDirectory(char const*)'
gdcmGlobal.cxx:-1: error: undefined reference to gdcm::System::FileExists(char const*)'
:-1: error: C:\Program_Library\gdcm-2.0.18-mingw32\bin/libgdcmDICT.a(gdcmGlobal.cxx.obj): bad reloc address 0xf in section.text$ZNK4gdcm7Modules7IsEmptyEv[_ZNK4gdcm7Modules7IsEmptyEv]'
I included the libs:
LIBS += -L"C:\Program_Library\gdcm-2.0.18-mingw32\bin" \
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmMSFF.a" \
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmCommon.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmDICT.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmDSED.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmexpat.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmIOD.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmjpeg8.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmjpeg12.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmjpeg16.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmopenjpeg.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmzlib.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmcharls.a"\
-L"C:\Program_Library\gdcm-2.0.18-mingw32\bin\libgdcmgetopt.a"
LIBS += -lgdcmMSFF -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmexpat
-lgdcmIOD -lgdcmjpeg8 -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmopenjpeg -lgdcmzlib -lgdcmcharls -lgdcmgetopt
Anybody would know what is happening?
Thanks!
Qt 5.1 uses g++ 4.8 and I used g++ 4.6 to compile gdcm! That is the problem! However when I included:
include < gdcmGlobal.h>
appear this error:
gdcmGlobal.cxx:-1: error: undefined reference to
`gdcm::System::FileIsDirectory(char const*)'
but when I remove: include < gdcmGlobal.h>, compiles!

undefined reference to `QSound::play(QString const&)'

Trying to play sound, via QSound (QT 5, Ubuntu 13.04)
The code:
#include <QtMultimedia/QSound>
void MainWindow::on_pushButton_2_clicked()
{
QSound::play("sounds/win.wav");
}
And getting 2 errors:
undefined reference to `QSound::play(QString const&)'
collect2: error: ld returned 1 exit status
What am i doing wrong ? In documentation here i see the same code.
You need to include the multimedia module. Add this to your .pro file:
QT += multimedia

How to integrate openNI in Qt in Ubuntu?

Currently I am making a project on recognizing human actions using Kinect. Since I work in Ubuntu and I need the skeleton information, I choose openNI and NITE. I want to use Qt to create a GUI application, but I don't know how to integrate openNI in Qt. All the samples of openNI and NITE run well, but I failed to build any of them in Qt creator. I really hope anyone can help me on this(Say how to build NiUserTracker in Qt creator). I will also apriciate it if anyone can give some sample Qt projects.
I have tried to build NiUserTracker in Qt creator:
Content of .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
INCLUDEPATH += /home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Include
SOURCES += main.cpp \
SceneDrawer.cpp \
opengles.cpp
HEADERS += \
SceneDrawer.h \
opengles.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/release/ -lnimCodecs
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/debug/ -lnimCodecs
else:symbian: LIBS += -lnimCodecs
else:unix: LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/ -lnimCodecs
INCLUDEPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
DEPENDPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/release/ -lnimMockNodes
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/debug/ -lnimMockNodes
else:symbian: LIBS += -lnimMockNodes
else:unix: LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/ -lnimMockNodes
INCLUDEPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
DEPENDPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/release/ -lnimRecorder
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/debug/ -lnimRecorder
else:symbian: LIBS += -lnimRecorder
else:unix: LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/ -lnimRecorder
INCLUDEPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
DEPENDPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/release/ -lOpenNI
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/debug/ -lOpenNI
else:symbian: LIBS += -lOpenNI
else:unix: LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/ -lOpenNI
INCLUDEPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
DEPENDPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/release/ -lOpenNI
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/debug/ -lOpenNI
else:symbian: LIBS += -lOpenNI
else:unix: LIBS += -L$$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib/ -lOpenNI
INCLUDEPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
DEPENDPATH += $$PWD/../../../../../../../../../../home/myname/Kinect/OpenNI-Bin-Dev-Linux-x86-v1.5.4.0/Lib
I have added the inlcude path of openNI and libs, however when I built the program, it shows:
SceneDrawer.o: In function `initTexture(void**, int&, int&)':
SceneDrawer.cpp:(.text+0x45): undefined reference to `glGenTextures'
SceneDrawer.cpp:(.text+0x9c): undefined reference to `glBindTexture'
SceneDrawer.cpp:(.text+0xb8): undefined reference to `glTexParameteri'
SceneDrawer.cpp:(.text+0xd4): undefined reference to `glTexParameteri'
SceneDrawer.o: In function `DrawRectangle(float, float, float, float)':
SceneDrawer.cpp:(.text+0x144): undefined reference to `glVertexPointer'
SceneDrawer.cpp:(.text+0x160): undefined reference to `glDrawArrays'
SceneDrawer.cpp:(.text+0x165): undefined reference to `glFlush'
SceneDrawer.o: In function `DrawTexture(float, float, float, float)':
SceneDrawer.cpp:(.text+0x19b): undefined reference to `glEnableClientState'
SceneDrawer.cpp:(.text+0x1bf): undefined reference to `glTexCoordPointer'
SceneDrawer.o: In function `glPrintString(void*, char*)':
SceneDrawer.cpp:(.text+0x22f): undefined reference to `glutBitmapCharacter'
SceneDrawer.o: In function `DrawLimb(unsigned int, XnSkeletonJoint, XnSkeletonJoint)':
SceneDrawer.cpp:(.text+0x24c): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x306): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x3da): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x488): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x5ab): undefined reference to `g_DepthGenerator'
SceneDrawer.cpp:(.text+0x5ef): undefined reference to `glVertex3i'
SceneDrawer.cpp:(.text+0x62b): undefined reference to `glVertex3i'
SceneDrawer.cpp:(.text+0x65a): undefined reference to `g_UserGenerator'
SceneDrawer.o: In function `drawCircle(float, float, float)':
SceneDrawer.cpp:(.text+0x7e0): undefined reference to `glBegin'
SceneDrawer.cpp:(.text+0x841): undefined reference to `glVertex2f'
SceneDrawer.o: In function `DrawJoint(unsigned int, XnSkeletonJoint)':
SceneDrawer.cpp:(.text+0x869): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x91d): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x9d2): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0xabf): undefined reference to `g_DepthGenerator'
SceneDrawer.o: In function `DrawDepthMap(xn::DepthMetaData const&, xn::SceneMetaData const&)':
SceneDrawer.cpp:(.text+0xdb7): undefined reference to `g_bDrawPixels'
SceneDrawer.cpp:(.text+0xf0c): undefined reference to `g_bDrawBackground'
SceneDrawer.cpp:(.text+0xf85): undefined reference to `glBindTexture'
SceneDrawer.cpp:(.text+0xfd4): undefined reference to `glTexImage2D'
SceneDrawer.cpp:(.text+0xff8): undefined reference to `glColor4f'
SceneDrawer.cpp:(.text+0x1004): undefined reference to `glEnable'
SceneDrawer.cpp:(.text+0x1052): undefined reference to `glDisable'
SceneDrawer.cpp:(.text+0x108f): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x10d1): undefined reference to `g_bDrawSkeleton'
SceneDrawer.cpp:(.text+0x10f4): undefined reference to `g_bPrintID'
SceneDrawer.cpp:(.text+0x1107): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x1114): undefined reference to `g_DepthGenerator'
SceneDrawer.cpp:(.text+0x115b): undefined reference to `g_bPrintState'
SceneDrawer.cpp:(.text+0x11d6): undefined reference to `glColor4f'
SceneDrawer.cpp:(.text+0x1210): undefined reference to `glRasterPos2i'
SceneDrawer.cpp:(.text+0x121b): undefined reference to `glutBitmapHelvetica18'
SceneDrawer.cpp:(.text+0x1225): undefined reference to `g_bDrawSkeleton'
SceneDrawer.cpp:(.text+0x1233): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x1348): undefined reference to `glColor4f'
SceneDrawer.cpp:(.text+0x134e): undefined reference to `g_bMarkJoints'
SceneDrawer.cpp:(.text+0x1362): undefined reference to `glBegin'
SceneDrawer.cpp:(.text+0x154b): undefined reference to `glEnd'
SceneDrawer.cpp:(.text+0x155a): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x187a): undefined reference to `g_UserGenerator'
SceneDrawer.cpp:(.text+0x1b02): undefined reference to `g_bPrintFrameID'
SceneDrawer.cpp:(.text+0x1b87): undefined reference to `glColor4f'
SceneDrawer.cpp:(.text+0x1b9b): undefined reference to `glRasterPos2i'
SceneDrawer.cpp:(.text+0x1baa): undefined reference to `glutBitmapHelvetica18'
SceneDrawer.o: In function `DrawTexture(float, float, float, float)':
SceneDrawer.cpp:(.text+0x1f3): undefined reference to `glDisableClientState'
SceneDrawer.o: In function `drawCircle(float, float, float)':
SceneDrawer.cpp:(.text+0x854): undefined reference to `glEnd'
collect2: ld returned 1 exit status
I guess it is because the glut libs are not included. However both libs are .lib files, which seems cannot be added in Qt creator....
Thank you very much!
did you tried to use openNI with openCV + qt support?
another soluction is this.
http://develnoter.blogspot.com.br/2012/05/integrating-opencv-in-qt-gui.html

Resources