I've been trying to compile a project for the past two days in Qt using OpenCV but can't figure out why it doesn't. My application has only main.cpp, widget.cpp and widget.h
here is my .pro file
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FaceDetect
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
INCLUDEPATH += C:/opencv/build/include/
LIBS += -LC:/opencv/build/x64/vc10/lib/
-libopencv_core2410
-libopencv_highgui2410
-libopencv_imgproc2410
-libopencv_features2d2410
-libopencv_calib3d24610
and these are the errors I keep getting:
main.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release#Mat#cv##QAEXXZ)
moc_widget.obj:-1: error: LNK2001: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ)
moc_widget.obj:-1: error: LNK2001: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ)
Can anyone explain why and how I an get rid of these please?
Thanks!
Put a slash at the end of every file in LIBS and save it.
LIBS += -LC:/opencv/build/x64/vc10/lib/
-libopencv_core2410 \
-libopencv_highgui2410 \
-libopencv_imgproc2410 \
-libopencv_features2d2410 \
-libopencv_calib3d24610
Now right click the project folder and click "Run qmake" and then 'build' it, this will 'make' the file and consider the changes made in .pro file.
Related
I use Qt Add-in in my project. But i dont understand , what i do uncorrect.
My .pro file:
QT += core gui network
TEMPLATE = app
TARGET = MMworker
DESTDIR = ../Debug
CONFIG += debug
LIBS += -L"../../../../boost_1_70_0/stage/lib"
DEPENDPATH += .
MOC_DIR += .
OBJECTS_DIR += debug
UI_DIR += .
RCC_DIR += .
Get a lot of errors. For example
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::QHostAddress(void)" (__imp_??0QHostAddress##QAE#XZ) referenced in function...
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall QHostAddress::setAddress(class QString const &)" (__imp_?setAddress#QHostAddress##QAE_NABVQString###Z) referenced in function ...
Error LNK2019 unresolved external symbol "public: void __thiscall TcpServer::connectToServer(class QHostAddress,int)" (?connectToServer#TcpServer##QAEXVQHostAddress##H#Z) referenced in function...
Error LNK2019 unresolved external symbol "public: bool __thiscall MainTimer::timeAfterMomentExceeds(__int64,__int64)" (?timeAfterMomentExceeds#MainTimer##QAE_N_J0#Z) referenced in function ...
Error LNK2019 unresolved external symbol "private: __int64 __thiscall MainTimer::getMilliseconds(void)" (?getMilliseconds#MainTimer##AAE_JXZ) referenced in function "public: __int64 __thiscall MainTimer::time_ms(void)" (?time_ms#MainTimer##QAE_JXZ)...
Error LNK2019 unresolved external symbol "public: void __thiscall Channel::readData(class QString &)" (?readData#Channel##QAEXAAVQString###Z) referenced in function ...
Error LNK2001 unresolved external symbol "public: virtual void * __thiscall SimpleDevice::qt_metacast(char const *)" (?qt_metacast#SimpleDevice##UAEPAXPBD#Z)...
P.S.: Also I look in qt simple tcp communication with ui projects . I dont understand how I can "You need to enable modules you're using in Qt Project Settings".
UPD1: compile was sucsess, but build still falling.
Error was in inlcude additional dependensies(removed) and included dirs(added)
I'm building a project using Qt Creator, which at the same time, using QuickFIX library. When I try to build the project using MSVC 2015 32bits build, it always has these two kinds of linker error:
error: LNK2019: unresolved external symbol "private: static double __cdecl FIX::DoubleConvertor::fast_strtod(char const *,int,int *)" (?fast_strtod#DoubleConvertor#FIX##CANPBDHPAH#Z) referenced in function "public: static bool __cdecl FIX::DoubleConvertor::convert(class
std::basic_string,class std::allocator > const &,double &)" (?convert#DoubleConvertor#FIX##SA_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAN#Z)
error: LNK2001: unresolved external symbol "private: static double __cdecl FIX::DoubleConvertor::fast_strtod(char const *,int,int *)" (?fast_strtod#DoubleConvertor#FIX##CANPBDHPAH#Z
But I'm not using these double convertor anywhere in my project and I thought the quickfix library should have export all function from its source.
I've tried it on 64bits or MSVC 2017 build, nothing works..
I've been trying these for several weeks... It's driving me crazy
edit: my .pro file:
DEPENDPATH += $$(QuickFIX_VS2017)/include/quickfix
INCLUDEPATH += $$(QuickFIX_VS2017)/include/quickfix
Debug:LIBS += -L$$(QuickFIX_VS2017)/x64/Debug/ -lquickfix
Debug:PRE_TARGETDEPS += $$(QuickFIX_VS2017)/x64/Debug/quickfix.lib
Release:LIBS += -L$$(QuickFIX_VS2017)/x64/Release -lquickfix
Release:PRE_TARGETDEPS += $$(QuickFIX_VS2017)/x64/Release/quickfix.lib
I'm new and trying to use Quazip under qt 5.5. So I just downloaded project sources from http://quazip.sourceforge.net/ and opened .pro file. When I try to build project I 've got multiple errors:
C1083: Cannot open include file: 'zlib.h': No such file or directory
To avoid building zlib on windows I just installed (from here: http://gnuwin32.sourceforge.net/packages/zlib.htm) complete pack for windows in C:\GnuWin32. Then I added this line in .pro file:
INCLUDEPATH += C:\GnuWin32\include
This generated another error:
Cannot open include file: 'unistd.h': No such file or directory
But changing this line
#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */
into this fixed the problem.
#if HAVE_UNISTD_H
Unfortunately now I get 25 unresolved external symbols, some of them:
quaadler32.obj:-1: error: LNK2019: unresolved external symbol adler32 referenced in function "public: virtual unsigned int __cdecl QuaAdler32::calculate(class QByteArray const &)" (?calculate#QuaAdler32##UEAAIAEBVQByteArray###Z)
quacrc32.obj:-1: error: LNK2019: unresolved external symbol crc32 referenced in function "public: virtual unsigned int __cdecl QuaCrc32::calculate(class QByteArray const &)" (?calculate#QuaCrc32##UEAAIAEBVQByteArray###Z)
unzip.obj:-1: error: LNK2001: unresolved external symbol crc32
quagzipfile.obj:-1: error: LNK2019: unresolved external symbol gzopen referenced in function "private: void * __cdecl QuaGzipFilePrivate::open(class QString const &,char const *)" (?open#QuaGzipFilePrivate##AEAAPEAXAEBVQString##PEBD#Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol deflateInit_ referenced in function "public: virtual bool __cdecl QuaZIODevice::open(class QFlags<enum QIODevice::OpenModeFlag>)" (?open#QuaZIODevice##UEAA_NV?$QFlags#W4OpenModeFlag#QIODevice#####Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol inflate referenced in function "protected: virtual __int64 __cdecl QuaZIODevice::readData(char *,__int64)" (?readData#QuaZIODevice##MEAA_JPEAD_J#Z)
I tries adding this line:
LIBS += -LC:\GnuWin32\lib
But that didn't solve the problem. WHat is the easiest way to use Quazip under Qt?
Download quazip source from quzip site
Open by Qt Creator quazip.pri
Replace all strings #include "zlib.h" or "#include < zlib.h>"
to
#include <QtZlib/zlib.h>
Build project and run unit tests.
I have an empty project, and I added a QAxWidget in Qt Designer. The project compiled before adding the QAxWidget, but now it fails with this linker error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall QAxWidget::QAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0QAxWidget##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z) referenced in function "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi#Ui_MainWindow##QAEXPAVQMainWindow###Z)
Should I change something in my .pro file, add some module perhaps?
Found the answer after some searching, it turned out I need to add this to my .pro file:
LIBS += qaxcontainer.lib
I have QT installed in my PC, which is using the Visual Studio 2010 compiler
I tested this with a simple hello world application, and it works fine.
However now I am trying to use OpenCV with QT. I have installed Visual Studio 2010 express and professional both, and opencv works fine there. But, when I try to run the OpenCV in QT, I get the following error
main.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release#Mat#cv##QAEXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPAX#Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat#cv##QAE#XZ)
main.obj:-1: error: LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow#cv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV_InputArray#1##Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QAE#ABVMat#1##Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?namedWindow#cv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread#cv##YA?AVMat#1#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function _main
release\FirstProject.exe:-1: error: LNK1120: 7 unresolved externals
Following is my FirstProject.pro file's content
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-26T11:15:33
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = FirstProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\opencv\build\include\
LIBS += -LC:\opencv\build\x86\vc10\lib \
-lopencv_calib3d240d.lib\
-lopencv_contrib240d.lib\
-lopencv_core240d.lib\
-lopencv_features2d240d.lib\
-lopencv_flann240d.lib\
-lopencv_gpu240d.lib\
-lopencv_haartraining_engined.lib\
-lopencv_highgui240d.lib\
-lopencv_imgproc240d.lib\
-lopencv_legacy240d.lib\
-lopencv_ml240d.lib\
-lopencv_nonfree240d.lib\
-lopencv_objdetect240d.lib\
-lopencv_photo240d.lib\
-lopencv_stitching240d.lib\
-lopencv_ts240d.lib\
-lopencv_video240d.lib\
-lopencv_videostab240d.lib
I tried by chainging to the following FirstProject.pro content, but no good at all
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-26T11:15:33
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = FirstProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\opencv\build\include\
LIBS += -LC:\opencv\build\x86\vc10\lib \
-lopencv_core240 \
-lopencv_highgui240 \
-lopencv_imgproc240 \
-lopencv_features2d240 \
-lopencv_calib3d240
Following is my code
main.cpp
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image = imread("D:/Tulips.jpg");
if(!image.data)
{
cout << "Error loading image" << endl;
}
else
{
namedWindow("Image");
imshow("Image",image);
}
waitKey(0);
return 0;
}
Why am I getting this error?
QT Project files try to handle file/directory separators uniformly, ie, forward v's back slashes. It shouldn't matter which is used. However, maybe there's some translation going on.
Try replacing all backslashes '\' with forward versions '/'. Qmake will convert them appropriately.
Replace with -LC:/opencv/build/x86/vc10/lib
It also might be the final backslash on your INCLUDEPATH that's the problem. Maybe it's joining up next line?
I found the answer. The only way to remove the issue is adding the libs one by one, with the complete path
LIBS += C:/opencv/build/x86/vc9/lib/opencv_calib3d240.lib
LIBS += C:/opencv/build/x86/vc9/lib/opencv_contrib240.lib
I had the same problem but I found the answer nowhere. after 8 days trying to fix it finally I found the answer and I want to share it with u.
when u use static linking opencv first check if your libraries are really static linked , to do so open a developer command prompt msvc , navigate into your libraries path , and type the command bellow :
lib /LIBS opencv_world.lib
rather than opencv_world.lib you can put any other library names.
then check there were only refrenced .obj files in it , so that means u can use this library static.
then remember when u use static lib in opencv , u need to at some other libraries to ur project that in dynamic linking u didnt need to. these libraries are in your library directory that their name doesnt start with opencv.
u can see some of them bellow :
IlmImf.lib
ippicvmt.lib
ippiw.lib
ittnotify.lib
libjasper.lib
libtiff.lib
libwebp.lib
zlib.lib
remeber , If u got the error "couldnt find library" , use the exact path to add it. for example :
LIBS += E:\opencv\build-x86-static\install\x86\vc15\staticlib\zlib.lib