Qt: cannot find DLLs even if I specify their location - qt

I cannot understand why this Qt pro file does not work:
QT += core
QT += gui
TARGET = PrjName
CONFIG += qt
CONFIG += console
TEMPLATE = app
INCLUDEPATH += C:/Qt/4.8.4/include/Qt
QMAKE_LIBDIR += C:/Qt/4.8.4/bin
LIBS += -lQtCore4
LIBS += -lQtGui4
SOURCES += ...
HEADERS += ...
These are the linker errors:
error: cannot find -lQtGui
error: cannot find -lQtCore
The C:\Qt\4.8.4\bin directory exists, and the DLLs are there.
Thank you.
Platform: Windows 7, MinGW, Qt 4.8.4, QtCreator 2.8.0

Related

Qt5 OpenCV3.4.5 LNK1105 cannot open opencv_world345d.obj

I am building a Qt5 project with OpenCV3.4.5 in windows. The OpenCV is a prebuilt version with opencv_world345.lib and opencv_world345dlib. I create a .pri file for including opencv into the Qt project. Here below is for the opencv .pri file:
INCLUDEPATH += C:/opencv-3.4.5/prebuild/include \
C:/opencv-3.4.5/prebuild/include/opencv \
C:/opencv-3.4.5/prebuild/include/opencv2
Debug: {
LIBS += lc:/opencv-3.4.5/prebuild/x64/vc14/lib/opencv_world345d
}
Release: {
LIBS += lc:/opencv-3.4.5/prebuild/x64/vc14/lib/opencv_world345
}
I also set C:\opencv-3.4.5\prebuild\x64\vc14\bin in the path of systems variables.
Building the project in debug mode gives the error: LINK : fatal error LNK1104: cannot open file 'lc:\opencv-3.4.5\prebuild\x64\vc14\lib\opencv_world345d.obj'.
What causes the error? Do I miss something else in configuring opencv for Qt?
Have you run qmake since making your changes to the .pri file?
Normally I would have asked for clarification in the comments, but I'm new to Stack Overflow and don't have 50 reputation yet.
EDIT:
I found an old project of mine that I have OpenCV3.1.0 properly linked to. Here's what I have in my .pro
LIBS += -L*PATH TO OPEN CV*/OpenCV-3.1.0/lib
INCLUDEPATH += *PATH TO OPEN CV*/OpenCV-3.1.0/include
CONFIG(release, debug|release):{
LIBS += \
-lopencv_world310
}
CONFIG(debug, debug|release):{
LIBS += \
-lopencv_world310d
}
Here below is the modified .pri file that works for me!
INCLUDEPATH += c:/opencv-3.4.5/prebuild/include
CONFIG(release, debug|release):{
LIBS += -L"c:/opencv-3.4.5/prebuild/x64/vc14/lib" -lopencv_world345
}
CONFIG(debug, debug|release):{
LIBS += -L"c:/opencv-3.4.5/prebuild/x64/vc14/lib" -lopencv_world345d
}
The configurations by Debug:{} and Release {} do not work!

Qt error: undefined reference to 'QDebug::~QDebug()'

I am compiling my code with caffe, opencv 3.1 and Qt5.6. Following is my .pro file. I have not included the actual source and header file names here.
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = outsideSituationDetection
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
<and others>
HEADERS += mainwindow.h \
< and others >
FORMS += mainwindow.ui
DEFINES += CPU_ONLY
QMAKE_CXXFLAGS += -std=c++11 -Wall -D_REENTRANT -D__STDC_CONSTANT_MACROS -pthread
QMAKE_CXXFLAGS += -DQT_COMPILING_QSTRING_COMPAT_CPP -DQT_COMPILING_QIMAGE_COMPAT_CPP
CONFIG += link_pkgconfig
PKGCONFIG += opencv
INCLUDEPATH += /usr/local/include /usr/local/lib /usr/lib
DEPENDPATH += /usr/local/include
LIBS += -L/usr/local/lib/ -lopencv_imgproc
LIBS += -lm -lglib-2.0 -lgthread-2.0 -lxml2 -pthread
INCLUDEPATH += /usr/include/glib-2.0
INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include
INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += /usr/include/ \
/usr/lib/x86_64-linux-gnu/ \
LIBS += -L/usr/lib/x86_64-linux-gnu/ -lglog -lpthread -lm -lrt -ldl -lnsl
DEPENDPATH += /usr/lib/x86_64-linux-gnu/
# BOOST Library
LIBS += -L/usr/lib/x86_64-linux-gnu/ -lboost_system
INCLUDEPATH += /usr/lib/x86_64-linux-gnu
#Caffe for CPU System
INCLUDEPATH += $$PWD/../../../../../src/caffe/build/include \
$$PWD/../../../../../src/caffe/include \
$$PWD/../../../../../src/caffe/build
unix:!macx: LIBS += -L$$PWD/../../../../../src/caffe/build/lib/ -lcaffe -lglog
INCLUDEPATH += $$PWD/../../../../../src/caffe/build
DEPENDPATH += $$PWD/../../../../../src/caffe/build
RESOURCES += icons.qrc
Problem - When I compile the code, I get a bunch of 'error: undefined reference to 'QDebug::~QDebug()'' errors along with 'error: undefined reference to `QDebug::putString(QChar const*, unsigned long)'' against all of my .cpp files. (I have successfully built and executed another application without errors using Qt5.6 and Qt5.7.)
(.qtversion[qt_version_tag]+0x0):-1: error: undefined reference to `qt_version_tag' File not found (.qtversion[qt_version_tag]+0x0) in main.o
What I have tried - Check Qt version to make sure I am using Qt5.6. Deleted the installed qt5-default by doing 'sudo apt-get remove qt5-default'. Downgraded from Qt5.7 to Qt5.6 although it didn't make any difference. I have deleted qt4 and qt5 folders from /usr/include and /usr/share.
Can you please suggest what I might be missing?
I had multiple declarations of ' #include "QDebug" ' in files. Removing them and having it in only one file removed the error. (edit- it's incorrect and doesn't work)
What worked - Though I had removed older versions of Qt 3, 4 & 5 , qt was internally using 5.2.1 versions. I do not know where they came from. But when I deleted them all in /usr/lib/x86_linux_gnu/, the code compiled! I also specified the paths to the installed directory explicitly in qtchooser/default.conf. This may not be the best way to do but it worked anyway.

Qt in Ubuntu: Cannot compile using static boost libraries

I am trying to compile a C++ plugin using Ubuntu 14.04, Qt, and some boost libraries.
I built the boost libraries as follows:
libboost-all-dev
If I use shared boost libraries, e.g. libboost_system.so, the project compiles just fine. However, I want to compile using static boost libraries (libboost_system.a). I get the following error in my boost project:
"relocation R_X86-64-32 against '.rodata.str1.1' cannot be used when making a shared object; recompile with -fPIC".
This is my Qt project file:
VERSION = 1.3.1
TEMPLATE = lib
QT -= gui
CONFIG += warn_on plugin release
CONFIG -= thread exceptions qt rtti debug
CONFIG += c++11
INCLUDEPATH += /usr/include
LIBS += "/usr/lib/x86_64-linux-gnu/libboost_system.a"
LIBS += "/usr/lib/x86_64-linux-gnu/libboost_filesystem.a"
DEFINES += APL=0 IBM=0 LIN=1
DEFINES += IGOCONNECT_LIN_LIBRARY
TARGET = lin.xpl
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_CXXFLAGS += -fPIC
SOURCES += igoconnect_lin.cpp
HEADERS +=
unix {
target.path = /usr/lib
INSTALLS += target
}
Anything I am doing wrong? Thank you so much!
Try that
LIBS += -lboost_system

Linking dll to c++ in qt for reading .mat files

I am using Qt Creator 2.4.1(Based on Qt 4.7.4) ..
Now I want to open the .mat file which I got from Matlab.
I am using the basic function matOpen
Initially, I knew the headers required. They are mat.h, matrix.h and tmw.h.
Now, before running the code, I need to link the libraries. The required libraries as far as I know are libmat.dll and libmw.dll . I added them to the .pro file as follows.
QT += core
QT -= gui
TARGET = mat_open_test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += \
mat.h \
matrix.h \
tmwtypes.h
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop- Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmat.dll"
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmx.dll"
Still I get error as : undefined reference to matOpen.. m sure the problem is with the linking.. But I dunno how to solve it. and the compiler Qt is using is MinGw .
You are specifying library path only, not the libraries itself. Try
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug"
LIBS += -llibmx
LIBS += -llibmat

error: QNetworkReply: No such file or directory

Something is missing from the pro file it seems:
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += hello.h
SOURCES += hello.cpp
QT += webkit
Or there is some other problem?
$qmake -v
QMake version 2.01a
Using Qt version 4.7.0 in /opt/qtsdk-2010.05/qt/lib
This line was missing: QT += network in the .pro file.

Resources