Qt5 OpenCV3.4.5 LNK1105 cannot open opencv_world345d.obj - qt

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!

Related

How to fix 'LINK : fatal error LNK1181: cannot open input file 'Qt5Ftp.obj''?

I use Qt5.12.0, Qt Creator 4.8.0. So it doesn't contain QFtp but I need to use it. So I follow the way I found on the Internet, I put the .h, .lib, .prl, .dll files of Qt5Ftp to the corresponding directories in 'Qt\Qt5.12.0\5.12.0\msvc2017_64'. Then I built my project, the compiling process is successful, but there's an error in the linking process—
LINK : fatal error LNK1181: cannot open input file 'Qt5Ftp.obj'
I'd tried to rerun qmake, clean all, rebuild all, etc, everything I could try, but I still got this error.
Here's the content of the .pro file of my project—
QT += core gui network webenginewidgets
CONFIG += c++11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
include(qtsingleapplication/src/qtsingleapplication.pri)
TARGET = YunQuBrowser
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp\
mainwindow.cpp \
webview.cpp \
webpage.cpp \
ftpclient.cpp \
logfile.cpp \
cmdconfig.cpp
HEADERS += mainwindow.h \
webview.h \
webpage.h \
ftpclient.h \
logfile.h \
cmdconfig.h \
common.h
INCLUDEPATH += ./include
FORMS += mainwindow.ui
RESOURCES += \
YunQuBrowser.qrc \
RC_FILE = YunQuBrowserDesktopIcon.rc
CONFIG(debug, debug|release) {
LIBS += Qt5Ftpd
} else {
LIBS += Qt5Ftp
}
The last comment I post contains a mistake. The correct way is to change the whole CONFIG block into LIBS += -L"QFtp/qtftp_lib", which should be a directory, but not a path of a .lib file.

qtcreator project file depndancies and build order

I am using qtcreator with subdir project structure. The case is that:
I have 2 projects. Project A and B. After A compiles, then B, but in B, I must use the headers of A (classes, functions, etc.). I`ve found in wiki the depends and subdir project setup, but when I try to include class A from project A into class B into project B ( these names are for convininece ) it gives me undefined referencies. Here is my .pro file from main project (and subprojects respectively ):
#base pro file
TEMPLATE = subdirs
SUBDIRS += \
message \
daemon \
receiver
daemon.subdir = daemon
message.subdir = message
daemon.depends = message
subproject A:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
daemon.cpp \
logwriter.cpp
HEADERS += \
daemon.h \
logwriter.h \
defs.h
LIBS += -lpthread
subproject B:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
message.cpp \
main.cpp
HEADERS += \
message.h
So I need the project B classes into project A and further on when I extend the project.
Regards.
EDIT: A .pri example would be appreciated, if I'm going to set project A to be a library (-lclssA )
"undefined references" are generally link problems, not header include problems. You may have to link your project A with B if you need to use it.
e.g in A :
LIBS += ../path/to/libB.so
The simplest way is to include it as a lib, the easiest way was from qtcreator, rightclick on the dependee and "Add library" -> "Existing library from build tree". This will generate the following in the .pro:
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../message/release/ -lmessage
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../message/debug/ -lmessage
else:unix: LIBS += -L$$OUT_PWD/../message/ -lmessage
INCLUDEPATH += $$PWD/../message
DEPENDPATH += $$PWD/../message
However I am losing the ability to make tests for my message class in it's main class. So if there is a better way, I'd accept it.

Qt creator: include path for external lib not found

I'm trying to add net-snmp lib to my project using win7 + cygwin:
Project file seems to contain valid lib and path entries:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/usr/lib/
-lnetsnmp else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/usr/lib/ -lnetsnmpd
INCLUDEPATH += $$PWD/C:/usr/include DEPENDPATH += $$PWD/C:/usr/include
But I can't build the project, because include file is not found, also it exists under given directory physically (c:/usr/include/net-snmp/net-snmp-config.h)
../snmptest1221313123/main.cpp:1:38: fatal error: net-snmp/net-snmp-config.h: No such file or directory
#include
I've read all "add external lib" topics, but it doesn't help to solve this.
Re-running qmake, re-opening Qt creator, or running qmake -r from terminal doesn't help neither.
Remove $$PWD/ (both from include and libs) and try again: run qmake and rebuild.

Qt: cannot find DLLs even if I specify their location

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

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