I'm currently trying to import libssh into a Qt project I am working on. It appears that I have the library linked correctly as the project builds, but once I run the project it just crashes before anything really starts up. Which makes debugging difficult. If I comment out the line:
my_ssh_session = ssh_new();
Then everything runs as it should and no crash occurs. My .pro file looks like
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += sql
QT += script
QT += scripttools
QT += uitools
LIBS += -llibssh
INCLUDEPATH += $$quote(C:\libssh\include)
TARGET = white_wrapper
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
datafeeder.cpp \
dbfeeder.cpp \
xmlhelper.cpp \
hiddevice.cpp
HEADERS += mainwindow.h \
datasource.h \
datafeeder.h \
dbfeeder.h \
xmlhelper.h \
hiddevice.h
FORMS += mainwindow.ui
After looking online it looks like the problem could be dlls but after running a dll dependency application it looks like I have all the dlls needed so I guess I'm at a lose and would love some input thanks.
I was getting the same error message with libssh-0.7.1, Qt 5.2.1 and MinGW.
After some research it turned up that libssh
needs another two dynamic libraries which depends on: libeay32.dll and zlib1.dll. They are not included in libssh's distribution archive, therefore you have to download them yourself and copy next to libssh.dll (or somewhere on $PATH).
In my .pro file I have the following lines added (I installed libssh using their installer to Program Files (x86) directory):
# Libssh:
LIBS += -L$$PWD/'../../../../../Program Files (x86)/libssh/lib/' -lssh.dll
INCLUDEPATH += $$PWD/'../../../../../Program Files (x86)/libssh/include'
DEPENDPATH += $$PWD/'../../../../../Program Files (x86)/libssh/include'
Now my Qt application works without problems.
Related
I have a project that I've written in VS2017 that has a lot of static libraries and I've got to the point where I want to start refining the gui. To make sure I can use Qt I made a test subdir program using the tips in https://www.toptal.com/qt/vital-guide-qmake, the https://wiki.qt.io/SUBDIRS_-_handling_dependencies example, the https://github.com/rainbyte/example-qmake-subdirs and https://github.com/219-design/qt-qml-project-template-with-ci/tree/6af6488d74e1dc97a8cef545080074055a696e9a projects as well as several of the similar questions here on SO.
This consists of a subdir project called "project" with 2 sub-projects "app" and "library". These are both simple QtApplications created using the New Subproject wizard, with all the files except for main.cpp removed from "app", everything left in except for main.cpp in "library", the point being to make sure mainwindow.h in "library" is referenced from main.cpp in "app". Despite trying every example I can find I'm still getting the "'mainwindow.h' file not found" error.
According to all the examples I could find you should only need to add a few lines (#) to the wizard-produced .pro files and add an additional .pri file to the "library" project;
Directory structure;
project/
project.pro
app/
app.pro
main.ccp
library/
library.pro
mainwindow.h
mainwindow.ccp
mainwindow.ui
library.pri
project.pro;
TEMPLATE = subdirs
TARGET = project ##
SUBDIRS += \
app \
library
app.depends = library ##
app.pro;
TEMPLATE = app ##
TARGET = app ##
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
SOURCES += \
main.cpp
include(../library/library.pri) ##
library.pro;
TEMPLATE = lib ##
TARGET = library ##
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += shared ##
CONFIG += lib_bundle ##
SOURCES += \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
DISTFILES += \
library.pri ##
and the added library.pri file;
LIBTARGET = library
BASEDIR = $${PWD}
INCLUDEPATH *= $${BASEDIR}/include
LIBS += -L$${DESTDIR} -llibrary
I know this has been asked many times already but I can find no definitive solution, or rather no-one seems to have bothered to post their working solution. I'd really appreciate any help with this, I'd love to be able to use Qt and escape the purgatory of win32 ui creation.
You have this:
INCLUDEPATH *= $${BASEDIR}/include
But you don't have directory named include anywhere, it seems. So probably remove the /include part from above.
I'm trying to create a custom QGIS desktop application with Qt 5.9.1
I have downloaded OSGeo4W (x64) geospatial software set and the Github C++ QGIS samples but I'm facing an error at compile time:
Cannot open include file: 'qgsmapcanvas.h': No such file or directory
Actually none of the above headers files are under OSGeo4W folder:
#include <qgsapplication.h>
#include <qgsproviderregistry.h>
#include <qgssinglesymbolrenderer.h>
#include <qgsmaplayerregistry.h>
#include <qgsrasterlayer.h>
#include <qgsmapcanvas.h>
But..shouldn't they be in dll libraries (eg qgis_core, qgis_gui ... ) ?
Anyway, this is my *.pro file:
TEMPLATE = app
TARGET = qgis_example4
QT = sql network svg gui core xml
LANGUAGE= C++
INCLUDEPATH += "C:\\OSGeo4W64\\include"
LIBS += -L"C:\\OSGeo4W64\\apps\\qgis\\bin" -lqgis_core -lqgis_gui -lgdal_i -lgeos_c
DEFINES+=CORE_EXPORT=__declspec(dllexport)
DEFINES+=GUI_EXPORT=__declspec(dllexport)
CONFIG += qt gui exceptions stl warn_on debug thread
RESOURCES += resources.qrc
FORMS += mainwindowbase.ui
HEADERS = mainwindow.h
SOURCES = main.cpp \
mainwindow.cpp
PS: there is a similar question on stackiverflow but I repeated it because the answers given did not give the solution
Solved: the needed headers file could be found within the "qgis-dev" branch of the project.
OSGeo4W : For users that cannot use OSGeo4W for some reason or just prefer it there is also a weekly snapshot of qgis-dev from OSGeo4W as standalone installer
After the installation you can find header in:
C:/Program Files/QGIS 2.99/apps/qgis-dev/include
So this is my .pro file
TEMPLATE = app
TARGET = qgis_example4
QT = sql network svg gui core xml
LANGUAGE= C++
INCLUDEPATH += "C:/Program Files/QGIS 2.99/include"
INCLUDEPATH += "C:/Program Files/QGIS 2.99/apps/qgis-dev/include"
LIBS += -L"C:/Program Files/QGIS 2.99/apps/qgis-dev/bin" -lqgis_core -lqgis_gui
DEFINES+=CORE_EXPORT=__declspec(dllexport)
DEFINES+=GUI_EXPORT=__declspec(dllexport)
CONFIG += qt gui exceptions stl warn_on debug thread
RESOURCES += resources.qrc
FORMS += mainwindowbase.ui
HEADERS = mainwindow.h
SOURCES = main.cpp \
mainwindow.cpp
Although the files are now present, I still not able to run QGIS samples. Maybe I'll move to other sample or I'll do my custom basic application.
I am developing a C++ Software with OpenCV 3.1 and QT 5 under win7 64Bit System.
The uses compiler is the VS2010 32bit.
I have to use another lib, called GDAL. I built this lib, set PATH environment and set the project properties in QT. As soon as I include a single .h file of GDAL the developed program starts and the instantly ends. QT gives messages like “debugging started” “debugging ended”.
Set break points won’t be reached so the program isn’t even starting. The GDAL lib seems to be included correctly because the used GDAL variables and classes are indicated by the autocomplete function of QT.
I used dependency walker to see if some dll are not loaded. This tools tells me that the following dlls are missing. These dll don’t exist on the harddrive.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-COM-L1-1-1.DLL
API-MS-WIN-CORE-DEBUG-L1-1-1.DLL
API-MS-WIN-CORE-DELAYLOAD-L1-1-1.DLL
API-MS-WIN-CORE-ERRORHANDLING-L1-1-1.DLL
API-MS-WIN-CORE-FILE-L1-2-1.DLL
API-MS-WIN-CORE-FILE-L2-1-1.DLL
API-MS-WIN-CORE-HEAP-L1-2-0.DLL
API-MS-WIN-CORE-HEAP-OBSOLETE-L1-1-0.DLL
API-MS-WIN-CORE-JOB-L2-1-0.DLL
API-MS-WIN-CORE-KERNEL32-LEGACY-L1-1-1.DLL
API-MS-WIN-CORE-LIBRARYLOADER-L1-2-0.DLL
API-MS-WIN-CORE-LOCALIZATION-L1-2-1.DLL
API-MS-WIN-CORE-LOCALIZATION-OBSOLETE-L1-2-0.DLL`enter code here`
One dll called GPSVC.dll was downloaded from the web. I have read several threads that people have same issues. Some have been fixing these issues by installing redistributable packages. I have all available redistributable packages installed and VS2010 ultimate.
I am getting sick of this problem, does anyone have THE solution to fix? What programs are associated with these listed dlls.
Would downgrading of QT 5 to QT 4 solve the problem.
I haven’t found threads with these issues when QT 4 is used.
Any suggestions are welcome!
Thanks
edit:
just to make all this clear, I would like to give you an overview of my settings.
the windows Path variable looks like this:
E:\opencv31\build\install\x86\vc10\bin;
C:\Qt5\5.5\msvc2010\bin;
E:\GDAL\bin
the .pro file of the qt project:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AirportExtractor
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
imageanalyzer.cpp \
airport.cpp \
filterslider.cpp \
framewindows.cpp \
scribblearea.cpp \
HEADERS += mainwindow.h \
imageanalyzer.h \
airport.h \
filterslider.h \
framewindows.h \
scribblearea.h \
FORMS += mainwindow.ui \
filterslider.ui \
framewindows.ui \
INCLUDEPATH += E:/GDAL/include/
INCLUDEPATH += E:/opencv31/build/install/include/
LIBS += -LE:/opencv31/build/install/x86/vc10/lib -lopencv_calib3d310d \
-LE:/GDAL/lib -lgdal_i \
I added the following paths to the project settings:
INCLUDE E:\GDAL\include;
LIB E:\GDAL\lib;
I tried to create a simple Opencv application in Qt and upon running, the whole application is crashed. If I comment out the opencv related codes from the project, the project runs just fine.
What I did:
Downloaded the Qt 5.5.0 VS2013 64bit version
Downloaded the OpenCV 3.0
Downloaded the Cmake 3.3.2
There were already prebuilt binaries in when I extracted the Opencv package, But all tutorials on the net wanted me to recompile the source codes so did I. The package contains:
build
sources
created a new folder named mymade to hold the binaries next to the other two directories. So it now looks like this:
build
mymade
sources
Steps:
Fired up CMake, specified the source folder from the extracted files
and specified mymade as the output for binaries.
checked all options that had a opencv in their names, plus Qt! and configured it and subsequently generated the files.
This is the resulting contents:
So all is done and I now need to build the binaries. I opened OpenCV.sln and compiled the release and debug binaries. The dlls are placed inside bin directory, and the lib files are placed inside lib folder.
Now it's the time to configure the Qt projects .pro file, so I used the header files from build directory, and for libs I used the lib folder from mymade folder. This is the first configuration that I came up with, which compiles without any linker issues, but crashes just immediately.
The initial changes in project file :
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenCVTest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//*.lib
FORMS += mainwindow.ui
Doing this in project file as it was suggested by answers like this didn't do any good either:
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenCVTest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_core300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_highgui300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_imgcodecs300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_ml300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_objdetect300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_photo300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_shape300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_hal300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_flann300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_features2d300.lib
FORMS += mainwindow.ui
This fails as well:
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenCVTest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include
LIBS +=-L"L://Apps_Installation_Folder//opencv//mymade//lib//Release"
LIBS += -lopencv_core300 -lopencv_highgui300 -lopencv_imgcodecs300 -lopencv_ml300 -lopencv_objdetect300 -lopencv_photo300 -lopencv_hal300 -lopencv_shape300 -lopencv_flann300 -lopencv_features2d300
FORMS += mainwindow.ui
So what is the problem here?
Update
As it was pointed out by #Miki, Qt couldn't find the opencv dlls (the configs above were OK but), And to solve this problem, one only needs to add the directory containing dlls to the PATH variable, there you are good to go and everything should be fine now.
From the comments to question it turns out that the program didn't find OpenCV dll.
You can:
Copy the required dll in the same folder of the .exe
Add the folder containing the dll to the PATH. You need to restart Qt Creator for changes to take effect.
I'm doing some experimentation with Qt on the Mac just now but I can't get my widget to show up in my application.
I've used Qt on Windows before and to do this I would just reference the dll and promote a widget to my own class, using the appropriate header file. I've tried the same on Mac but just get a blank screen.
The steps that I went through were to build the library (which gives me several files, *.dylib, *.1.dylib, *.1.0.dylib and *.1.0.0.dylib) and use the "Add Library..." function on my main application project. I'm not sure what all of these different dylibs are for but I have tried copying all of them into /usr/lib and the Contents/Frameworks folder inside my application bundle.
Can anyone shed any light on what might be going wrong and the key differences between doing this simple test on Windows and Mac?
Thanks,
Alan
Edit: Added code for project file
#-------------------------------------------------
#
# Project created by QtCreator 2013-10-02T19:59:44
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestApp
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-TestLibrary
Desktop_Qt_5_1_0_clang_64bit-Debug/release/ -lTestLibrary
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-TestLibrary
Desktop_Qt_5_1_0_clang_64bit-Debug/debug/ -lTestLibrary
else:unix: LIBS += -L$$PWD/../build-TestLibrary-Desktop_Qt_5_1_0_clang_64bit-Debug/
lTestLibrary
INCLUDEPATH += $$PWD/../TestLibrary
DEPENDPATH += $$PWD/../TestLibrary