Qt running error "Executable does not exist" - qt

I installed Qt version 5 on Mac OSX and tried to build a simple project found on a book.
The project at first compiled and run correctly then I tried to do Clean all and Build all. At this point it seems to compile correctly, but when I try to run it, I am getting the following error:
Executable /Users/myMac/build-project_name-Desktop_Qt_5_5_1_clang_64bit-Debug/project_name.app/Contents/MacOS/project_name does not exist
Notice that the project folder is /Users/myMac/project_name
I had also to modify the file *.pro by adding QT += widgets because I got also the TARGET is empty error.
I tried to look for older questions but I did not find anything useful. Does anyone have any suggestion?
Here is my .pro file:
######################################################################
# Automatically generated by qmake (2.01a) Sun Mar 20 21:45:06 2016
######################################################################
QT += widgets
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += finddialog.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += finddialog.cpp main.cpp mainwindow.cpp`

I needed to exit and restart QtCreator to fix a similar issue, although my error is slightly different from the OP's.
I am using CMakeLists.txt projects in QtCreator and we have a complicated cross-platform set of hundreds of projects.
Here is what led to my problem and I just reproduced it in Qt Creator 4.4.0 to verify the steps:
I added a new, command-line utility project in a subdirectory (i.e. add_subdirectory in CMake) by copying another similar project - I forgot to change the name
I ran CMake and it failed because the name was defined previously
I corrected the name of the new project (to 'a_exp')
I reran CMake successfully and QtCreator located the new project, a_exp
I used QtCreator to build the executable, a_exp
I confirmed in the shell that I could run the executable, a_exp
When I attempted to run in QtCreator, I got an error like the OP
Here is the error:
Starting a_exp...
Executable a_exp does not exist.

Related

How To Compile QFtp Example in Qt 5?

I have application which uses QFtp class.I have made in Qt 4 version.
But now i want to complie QFtp classe in Qt5 but it's showing some error like:
'QFtp' doesn't name and type.
how to resolve this issue. I don't want to use QNetworkAccessManager. is there any way to this?
Thank you
For the sake of completeness, the steps to use the add-ons are:
Download the sources for the add-on from https://github.com/qt/qtftp
Extract the sources somewhere (e.g. Qt5.x.y/Src/qtmyaddon)
Open a console in that folder
Read readme.txt and run the appropriate commands with the latest QT version
Run qmake
Run make (or nmake or mingw32-make or whatever)
Run sudo make install (nmake install, mingw32-make install, ...)
In the .pro file of your project, add "QT += myaddon" (e.g. "QT += ftp")
Run qmake on your project
Compile your project

QtCreator (2.8.0), using shared libraries

I developing a GUI app with Qt 5.1 and QtCreator 2.8.0 and I'm using a shared library (also compiled with Qt 5.1).
This is what I'm using in the .pro file:
INCLUDEPATH += ../MyLib
QMAKE_LIBDIR += ../MyLib/build/release
LIBS += -lMyLib
Regarding the "Run Configuration" (QtCreator) and under Linux (Ubuntu 12.04) I set the LD_LIBRARY_PATH to "(...)/MyLib/build/release" and it works well. However, on Windows, appending the library path (.dll) to PATH doesn't work. I don't get any compiling nor linking errors but when I run the app it immediately exits. If I put the .dll on the same folder as the executable it runs without any problem. Am I missing something?
Hard to say from the information you gave. Surely Windows does find the dll if you put its path into PATH. But maybe your dll uses another dll, which is not in the normal search path?
You might want to try the dependency walker: http://www.dependencywalker.com/
If your dll is based on Qt it might be that it does not find necessary qt plugins.
Check this out: http://qt-project.org/doc/qt-4.8/deployment-windows.html#application-dependencies
Qt 4, but Qt 5 is the same in this regard.

Qt linker errors: cannot find -lQtCored

A problem with a Qt *.pro file:
TARGET = ProgName
TEMPLATE = app
CONFIG += console
QT += core
QT += gui
LIBS += -LC:\\Qt\\4.8.5\\bin
LIBS += -LC:\\Qt\\4.8.5\\lib
LIBS += -LS:\\lib
# LIBS += -lQtCored4 # not necessary
# LIBS += -lQtCore4
# LIBS += -lQtGuid4
# LIBS += -lQtGui4
SOURCES += ...
HEADERS += ...
I get these linker errors:
:-1: error: cannot find -lQtGuid
:-1: error: cannot find -lQtCored
collect2.exe:-1: error: error: ld returned 1 exit status
All the DLLs exist in the specified directories.
The documentation did not help much.
This pro file worked a few days ago, and it seems to have issues since I installed Qt 5.1 (this is not used, yet; I am still working with Qt4).
Platform: Windows 7, MinGW, Qt 4.8.4
You only need the following content:
TARGET = ProgName
TEMPLATE = app
CONFIG += console
QT -= gui
SOURCES += ...
HEADERS += ...
That is because core and gui are added to the QT variable automatically. In this particular case however, you can remove the gui default if you wish to build a console application as you seem. Although "CONFIG += console" could eventually do that for you. Besides this, everything will work automatically for you, so you do not need to pass the library path to the qt libraries and so forth. You would only need to use QT += widgets and similar lines if you used further Qt modules there are not there by default. Even then, you would not need to set the Qt library path as you did in your question.
Besides, if you wanna target cross-platform later, you may wish to add this:
CONFIG -= app_bundle
to avoid creating Mac bundle for console based applications.
If you have multiple versions of Qt installed as it seems, you need to use the qmake from the required version, and it will be fine. Just to give an example: I use qmake for Qt 5 on my Archlinux system, and qmake-qt4 for Qt4.
On windows, you should either have the desired qt installation bin in the path before the undesired, or you need to call desired qmake explicitly, something like C:\path\to\my\desired\qmake.
There's no need to link to any Qt libraries afaik.
If you're using Qt Creator you need to make sure Qt 4.8.4 is properly recognized in Tools - Options - Build & Run - Kits. Since you installed 5.1 this may no longer be true. Then set the 4.8.4 kit for your project and compile it (cleaning the build directory also helps sometimes).

Qt 4.5.2 - linux - change library root

I have 2 versions of Qt for different arm devices and different toolchains: Qt 4.5.2 and Qt 4.7.3. Both versions are supposed to be placed in /opt/onyx/arm directory :(
The following error is occurred if I move the 1st Qt build in another directory (/usr/arm-marvell-linux-gnueabi) and run qmake:
#!/bin/sh
export QTDIR=/usr/arm-marvell-linux-gnueabi
/usr/arm-marvell-linux-gnueabi/bin/qmake -o Makefile.qt.onyx.a6x -spec qws/arm-marvell-linux-gnueabi-g++ project.pro
./run_qmake1.sh
Could not find mkspecs for your QMAKESPEC(qws/arm-marvell-linux-gnueabi-g++) after trying:
/opt/onyx/arm/mkspecs
Error processing project file: project.pro
What could be the issue and how can I resolve the /opt/onyx/arm conflict?
I would recommend grepping through /usr/arm-marvell-linux-gnueabi for any references to /opt/onyx. If you can't successfully change them (because they're in a binary), you could use symlinks to switch toolchains as needed.

Libqxt under Qt Creator

I want to create a tiny app which needs global shortcuts. So, I have downloaded the current version of libqxt (0.5.1) and opened as a project in Qt Creator.
Libqxt compiles without problems in this way, so I thought that adding this in the tab Dependencies of my project it would get added automatically in the build, like Eclipse does with JAR libraries (I know that are different IDEs but it seems to be a common feature among them).
What happens? Qt Creator compiles qxt before my project, when needed, but when I want to include its headers Qt Creator keeps warning me that it cannot find them.
Probably I am missing the correct name of headers (I tried the headers showed in qxt documentation: http://doc.libqxt.org/0.5.0/classQxtGlobalShortcut.html)
By the way, I looked the code for global shortcuts and I think I can rip it out and use it in my app as is and I am going to credit qxt team and open the code of my app.
from the documentation
Add the following lines to your .pro file:
CONFIG += qxt
QXT += core gui
Note: While building the Qxt on Linux do not forget to do a sudo make install otherwise this little piece of magic may fail to work.
Qt Creator doesn't know how to expose different libraries to your projects. It's developer's duty. Dependency ensures only that mentioned projects are already built before building your main project.
Your real concern was using Qxt without proper installation. Assuming that configure have been run and libqxt have been built (using Qt Creator or manually via qmake+make), my solution is adding following snippet (with obvious QXT_DIR customization) to .pro file:
QXT_DIR = $${IN_PWD}/../libqxt-0.5.1
LIBS += -L$${QXT_DIR}/deploy/libs
INCLUDEPATH += $${QXT_DIR}/deploy/include
for(module, QXT) {
MODNAME = $$upper($$replace(module, "(.).*", "\1"))$$replace(module, "^.", "")
INCLUDEPATH += $${QXT_DIR}/deploy/include/Qxt$${MODNAME}
INCLUDEPATH += $${QXT_DIR}/src/$${module}
win32:CONFIG(debug, debug|release):MODNAME = $$join(MODNAME,,,d)
LIBS += -lQxt$${MODNAME}
}
Unfortunately I'm not sure whether it works in complex projects.
By default Qxt is built in release mode, but Qt Creator uses debug mode and it leads to broken binaries of projects depending on Qxt under Windows. You have to switch your project to release mode or build Qxt in debug mode (run configure -debug and rebuild Qxt).
Last thing: In Windows you won't be able to run your project from Qt Creator even if you successfully build it. You must copy needed Qwt*.dll files (use the d-suffix versions if you're in debug mode) from libqxt-0.5.1/deploy/libs to your_project/(release|debug) directory .

Resources