Can't get Qt Creator to Properly Compile OpenCV - c++

I am trying to compile a Qt project and it seems like OpenCV is having problems. From what I have read so far, this could likely be a compiler/linkage problem. I have tried a couple different compilers without any success. Other libraries seem to be fine (libtiff, STD, other Qt libraries), but OpenCV is causing problems. I haven't for the life of me been able to make any progress on fixing it, any suggestions would be much appreciated. Posted below are things that I believe might be valuable in finding a solution.
Qt Makefile (.pro):
QT += core gui multimedia widgets multimediawidgets opengl
TARGET = LAUWebCalTag
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
laumemoryobject.cpp \
lauwebcamerawidget.cpp \
lauvideosurface.cpp \
lauvideoglwidget.cpp \
laucaltagglwidget.cpp \
laucaltagglobject.cpp
HEADERS += \
laumemoryobject.h \
lauwebcamerawidget.h \
lauvideosurface.h \
lauvideoglwidget.h \
laucaltagglwidget.h \
laucaltagglobject.h
RESOURCES += lauwebcameracapture.qrc
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
win32 {
INCLUDEPATH += $$quote(C:\Users\Sam\Downloads\opencv\build\include) $$quote(C:/usr/include)
INCLUDEPATH += $$quote(C:\Users\Sam\Downloads\tiff-4.0.9\tiff-4.0.9\libtiff)
DEPENDPATH += $$quote(C:\Users\Sam\Downloads\opencv\build\include) $$quote(C:/usr/include)
LIBS += -L$$quote(C:\usr\libs) -lopengl32
LIBS += -L$$quote(C:\Users\Sam\Downloads\opencv\build\x64\vc12\lib)
LIBS += -L$$quote(C:\Users\Sam\Downloads\tiff-4.0.9\tiff-4.0.9\libtiff) -llibtiff_i
CONFIG(release, debug|release): LIBS += -lopencv_world310
CONFIG(debug, debug|release): LIBS += -lopencv_world310d
}
Issues:
[Screenshot of Resulting Compile Issues]
Build and Run:
[Build and Run Kit Options]
[CMake (Not 100% sure if CMake is necessary for this project or right)]
I also thought the way cv:: was being declared was strange for this:
namespace cv
{
using std::vector;
}
I apologize for the dumb question, I am brand new to both Qt and OpenCV

Related

how to edit the qt .pro file for debug and release modes for opencv in c++

opencv c++ works fine but im checking if its running the opencv release and debug lib files. they seem to give me the same 20fps in release and debug (im testing by checking the fps of my camera video in opencv) is there a better way to test this? and is my .pro file correct?
opencv was built from source using vs, this is my .pro file
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
INCLUDEPATH += E:\\buildsfullsize\\cvbuild\\install\\include
debug {
LIBS +=-LE:\\buildsfullsize\\cvbuild\\install\\x64\\vc16\\lib \
-lopencv_aruco430d \
-lopencv_bgsegm430d \
#more lib files
-lopencv_xobjdetect430d \
-lopencv_xphoto430d
}
release {
LIBS +=-LE:\\buildsfullsize\\cvbuild\\install\\x64\\vc16\\lib \
-lopencv_aruco430 \
-lopencv_bgsegm430 \
#more lib files
-lopencv_xobjdetect430 \
-lopencv_xphoto430
}

Link Boost with Qt Creator on Mac

I have installed boost using Homebrew and got everything set up in my .pro file.
myProFile
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
src/nmea-tests.cpp \
src/position.cpp \
src/utilities.cpp \
src/parsenmea.cpp
HEADERS += \
headers/parseNMEA.h \
headers/position.h \
headers/types.h \
headers/utilities.h
INCLUDEPATH += headers/
LIBS += -lboost_unit_test_framework
macx {
QMAKE_CFLAGS += -std=c++11 -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++
LIBS += -L"/usr/local/Cellar/boost/1.63.0/lib" -lboost_random
INCLUDEPATH += "/usr/local/Cellar/boost/1.63.0/include"
}
However, when I try to build the project, Qt can't find boost/test/unit_test.hpp file
Compiler Error Message:
/Users/hadyfarhat/Documents/ntu/courses/soft/task4/gps/src/nmea-tests.cpp:3: error: 'boost/test/unit_test.hpp' file not found
#include <boost/test/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~
I would say the better way is using /usr/local/opt/boost for Intel and /opt/homebrew/opt/boost for Apple Silicon in your case. Then you don't need to worry about the problem of the version.
I had to change boost version from 1.63.0 to 1.66.0.
For Future problems with boost use my question as a guide and be sure to install homebrew before that.

No rule to make target

I am trying to make QT application using C++ language which will record the video from analogue camera. so I included the videoInput.h and videoInput.lib files in my project but when i am trying to run the my project then the following error occurs.
the error is:
mingw32-make[1]: No rule to make target path/to/videoInputd.lib', needed by 'debug\test.exe'. Stop.
please give me the solution.
thanks for help.
Thanks for your reply. I already added LIBS.
My .pro file is
QT += core gui
QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
../../../"Qt Projects/Test projects/test" \
videoInput.h
FORMS += mainwindow.ui
INCLUDEPATH += E:\\ImageProcessing\\opencv_cmake_binaries\\install\\include
LIBS += -LE:\\ImageProcessing\\opencv_cmake_binaries\\install\\lib \
-lopencv_core244.dll \
-lopencv_highgui244.dll \
-lopencv_imgproc244.dll \
-lopencv_features2d244.dll \
-lopencv_calib3d244.dll
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -lvideoInput
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -lvideoInputd
INCLUDEPATH += $$PWD/../../../"Qt Projects/Test projects/test/videoInput"
DEPENDPATH += $$PWD/../../../"Qt Projects/Test projects/test/videoInput"
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/videoInput.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/videoInputd.lib
end of .pro file.
and I changed the build mode to release mode and then try to run then new error comes. The error is
error: redefinition of 'bool comInit'
error: 'bool comInit' previously declared here
static bool comInit;
error: redefinition of 'class videoInput'
class videoInput{
error: previous definition of 'class videoInput'
class videoInput{
These four errors are in videoinput.h file the compiler shows me like this.
And I know the file name is videoInput.h but compile output shows me that videoInputd.lib, needed by debug\test.exe
Do as Sebastian tells (add videoInput.lib to LIBS) and switch build mode to release, since you have only release version of this library (videoInput.lib, not videoInputd.lib).
I got the solution. When I was trying to include videoInput.lib file in Qt creator, at that time it was displayed above mention error.
So I used qt-vs-addin which is available here. qt-vs-addin.
I designed GUI in qt-vs-addin using visual studio 2010 for my application and include videoInput.lib file in visual studio 2010 and now my application is ready. This will be helpful for someone.
Thanks to all.
I had similare problem "No tule ro mske tsrgrt. Th rrason was syntax error like
testwx:($(OBJS).... Check your syntax line by line

Compiling SDL2 in QtCreator (MinGW)

Run into a recent issue whilst trying to compile SDL2 with QtCreator using MinGW. It seems that for some reason the libraries are not linking.
I know 100% that the libraries are in the correct place, as you can see in this picture:
And how i'm linking in my .pro file:
##Windows
win32 {
TEMPLATE = app
CONFIG -= app_bundle
CONFIG -= qt
##Debug & Release Mode Configs
CONFIG(debug, debug|release) {
CONFIG += console
} else {
CONFIG -= console
}
INCLUDEPATH += "C:\Users\Daniel\Desktop\SDL2-devel-2.0.0-mingw\SDL2-2.0.0\x86_64-w64-mingw32\include\SDL2"
LIBS += -L"C:\Users\Daniel\Desktop\SDL2-devel-2.0.0-mingw\SDL2-2.0.0\x86_64-w64-mingw32\lib" \
-lmingw32 \
-lSDL2 \
-lSDL2main \
-lSDL2_ttf \
-lSDL2_image \
-lSDL2_mixer \
-lopengl32
}
Edit:
Well I was building with the wrong version of the libs! Doh! But a new problem arises, which i think has something to-do with SDLmain.. Must be missing something in my .pro file but totally unsure what :S
Well solved it. Link for any future reference;
http://www.cplusplus.com/forum/beginner/110753/
-lSDL2main needs to be before -lSDL2. Dammit.

Issue with Qt Creator LIBS path?

I'm having a simple yet extremely annoying problem with adding the external library files in QtCreator. I'm adding them via the following lines in .pro file:
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include)
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Release/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
LIBS += $$quote(-LD:/dcmtk-3.6.0/Lib files/Debug/) \
-ladvapi32 \
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
But every time it's giving the error :-1: error: LNK1181: cannot open input file 'files/Release).obj'.
I know the problem is occuring because of the spaces there, despite trying to follow the documentation it doesn't seem to work. I also think that may be QtCreator doesn't update the changes I'm trying to make. Any suggestions please? Thanks.
EDIT WITH SOLVED ANSWER:
I changed the codes in .pro file to this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
TARGET = NewApp
##QMAKE_CXXFLAGS_DEBUG += /MTd
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
DEFINES += _REENTRANT
QMAKE_CFLAGS_RELEASE -= -MD
QMAKE_CFLAGS_RELEASE = -MT
QMAKE_CFLAGS_DEBUG -= -MDd
QMAKE_CFLAGS_DEBUG = -MTd
QMAKE_CXXFLAGS_RELEASE -= -MD
QMAKE_CXXFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_DEBUG -= -MDd
QMAKE_CXXFLAGS_DEBUG += -MTd
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
INCLUDEPATH += $$quote(D:/dcmtk-3.6.0/Prefix Files/include/)
CONFIG( debug, debug|release ) {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Debug/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
else {
LIBS += $$quote(-LD:/dcmtk-3.6.0/LibFiles/Release/) \
-ladvapi32\
-ldcmdata\
-loflog\
-lofstd\
-lws2_32\
-lnetapi32\
-lwsock32\
}
Here I had to add the lines:
QMAKE_LFLAGS_DEBUG += /NODEFAULTLIB:msvcrtd.lib
QMAKE_LFLAGS_RELEASE += /NODEFAULTLIB:msvcrt.lib
Because, if you turn on MT, you must use /NODEFAULTLIB switch to ignore these libraries: libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib, otherwise you will get link problem.
And I also found the answer to LIB problems via this link where it's quoted:
"The normal
debug:LIBS += ...
else:LIBS += ...
solution breaks when users naively use CONFIG += debug or CONFIG += release to switch between debug and release builds (and they do; no-one remembers to say CONFIG -= release release_and_debug before CONFIG += debug :).
This is the canonical way to scope on debug:
CONFIG( debug, debug|release ) {
# debug
} else {
# release
}
"
Anyways, thanks a lot.
The right way to specify library link locations in a .pro file is actually via the QMAKE_LIBDIR variable:
QMAKE_LIBDIR += "D:/dcmtk-3.6.0/Lib files/Release/"
Your issue above is almost certainly because of missing quotes (the space is being interpreted as a argument break and you need it to be one argument).