app-file not running on different mac - c++

I have created an app-file with Qt. It contains openGL, Qt and c++ code.
My pro file looks like this:
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += openglscene.h \
glwidget.h
QT += opengl
OTHER_FILES +=
RESOURCES += \
images.qrc
mac: LIBS += -framework GLUT
else:unix|win32: LIBS += -lGLUT
FORMS +=
I get the following error message, when trying to run the app-file on a different mac:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Application Specific Information:
dyld: launch, loading dependent libraries
Dyld Error Message:
Library not loaded: /Developer/QtSDK/Desktop/Qt/473/gcc/lib/QtOpenGL.framework/Versions/Current/QtOpenGL
Referenced from: /Users/USER/Desktop/*/model.app/Contents/MacOS/model
Reason: image not found
The other macs dont have Qt installed. As it seems I somehow need to include an openGL-framework. How is it possible to do so that other users of my app would be able use it?

You need to include all your application's dependencies including Qt in the app bundle. qmake doesn't take care of this by itself. Qt comes with a little tool, macdeployqt, which might do what you need. A more sophisticated solution is using CMake and DeployQt4.cmake

Related

How to build crashpad for Qt application

I am developing Qt application and I would like to use crashpad to report crashes. I have downloaded sources and built them.
Now I would like to link those statically to my application.
When I go to out folder I see a lot of .a files. Which one should I choose?
> find ./out -name *.a
./obj/handler/libhandler.a
./obj/snapshot/libsnapshot.a
./obj/snapshot/libtest_support.a
./obj/test/libtest.a
./obj/test/libgtest_main.a
./obj/test/libgmock_main.a
./obj/util/libutil.a
./obj/third_party/mini_chromium/mini_chromium/base/libbase.a
./obj/third_party/gtest/libgtest_main.a
./obj/third_party/gtest/libgtest.a
./obj/third_party/gtest/libgmock.a
./obj/third_party/gtest/libgmock_main.a
./obj/minidump/libminidump.a
./obj/minidump/libtest_support.a
./obj/client/libclient.a
Also I have built it using this command:
build/gyp_crashpad.py -Dmac_deployment_target=10.12
I do not know if I should add some parameters
Could someone please help?
Thanks in advance
Build Crashpad via gn and ninja, where gn generates a build configuration, and ninja does the actual building.
For a macOS Qt application to generate minidumps and upload them to a remote server it will need to be linked with the Crashpad libraries libcommon.a, libclient.a, libutil.a, libbase.a, mig_output.a:
# Crashpad libraries
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lcommon
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lclient
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lbase
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lutil
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lmig_output
The application will also need to be linked with the system library bsm, and frameworks AppKit and Security:
# System libraries
LIBS += -L/usr/lib/ -lbsm
LIBS += -framework AppKit
LIBS += -framework Security
Additionally, you'll need to package crashpad_handler with your application and ensure that it is available at runtime.
More information about building Crashpad can be found here.
An example macOS Qt application that has been integrated with Crashpad can be found here.
Maybe type this in your code:
sys._excepthook = sys.excepthook
def my_exception_hook(exctype, value, traceback):
# Print the error and traceback
print(exctype, value, traceback)
# Call the normal Exception hook after
sys._excepthook(exctype, value, traceback)
sys.exit(1)
# Set the exception hook to our wrapping function
sys.excepthook = my_exception_hook
Also, import sys. This Code prints the error and reports it.

Qt application cannot find a 3rd party DLL and crashes

I am trying to build an application in QT that uses the libmodbus library. I am using MinGW 5.3 (Windows 7). The application will build without an error, but crashes when it attempts to run. The debug message says:
During startup program exited with code 0xc0000135
If I double-click the created executable file, there is an error that says:
libmodbus-5.dll is missing
from my computer.
Libmodbus was built with the same compiler. The include files are located in ../../codelibrary/MinGW63/libmodbus-master/src and the linker files are located in ../../codelibrary/QtMinGW53/libmodbus-master/src/.libs (.libs folder has both libmodbus.dll.a and libmodbus-5.dll).
If I add this library with Qt's 3rd party library wizard, then I get the following in my .pro file:
win32: LIBS += -L$$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.libs/ -llibmodbus.dll
INCLUDEPATH += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src
DEPENDPATH += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src
win32:!win32-g++: PRE_TARGETDEPS += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.libs/libmodbus.dll.lib
else:win32-g++: PRE_TARGETDEPS += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.libs/liblibmodbus.dll.a
This gives me the error:
-1: error: No rule to make target '../../codelibrary/MinGW63/libmodbus-master/src/.libs/liblibmodbus.dll.a', needed by 'debug\QTRosemount.exe'. Stop.
I then tried changing the .pro file to:
LIBS += -L$$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.libs/libmodbus-5.dll
INCLUDEPATH += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src
DEPENDPATH += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src
PRE_TARGETDEPS += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.libs/libmodbus.dll.a
This is when it will build without error and crash right away with code 0xc0000135 and a missing libmodbus-5.dll. I have tried many variations of the .pro paths that get this same error.
Note: I have been able to run console applications in Codeblocks with this library, not sure what I am running into with Qt.
How to fix this?
you can use an INSTALL SET and append it to the INSTALL list, as shown in QT documentation and illustrated below:
documentation.path = /usr/local/program/doc
documentation.files = docs/*
INSTALLS += documentation
For convenience, you may also use QMAKE_PRE_LINK. Now that you have some options, you may find further information in stackoverflow, such as in posts like this one.
Alternatively, I found that DEPENDPATH was incorrect. I have a folder in libmodbus that this needs to point to:
DEPENDPATH += $$PWD/../../codelibrary/QtMinGW53/libmodbus-master/src/.deps
The program compiles correctly with this changed

Importing libssh into Qt

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.

qt 5 looking for API-MS-WINxx.dll using GDAL headers

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;

QtCreator for iOS: How to deploy a dylib shared library with my application

I'm having a hard time deploying dynamic shared libraries on iOS.
To isolate and expose the problem, I have a very simple "HelloWorld" project: A library exporting class with a function returning "Hello World" and a program using the class and displaying the message.
I'm using QtCreator with Qt 5.5.
I'm able to generate the .dylib file and link my program. But, when I deploy it on the iPhone, I get the error:
Démarrage des processus distants.
dyld: Library not loaded: libMyLib.1.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/D6942CCE-828D-4C10-86DA-F7DA7ADF7449/MyApp.app/MyApp
Reason: image not found
On Android, I had the same kind of issue and could fix it by manually adding the shared library to the final package (apk) file, using ANDROID_EXTRA_LIBS. But I can find no equivalent for iOS.
Here are my .pro files. Full project can be downloaded here. I reported this to Qt as a bug, but if one could propose a kind of workaround this would help!
MyLib.pro:
QT -= core gui
TARGET = MyLib
TEMPLATE = lib
DEFINES += MYLIB_LIBRARY
SOURCES += mylib.cpp
CONFIG += shared
HEADERS += mylib.h\
mylib_global.h
MyApp.pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
dialog.cpp
HEADERS += dialog.h
INCLUDEPATH += ../MyLib
LIBS += ../MyLib/libMyLib.dylib
I'd like the solution to be all embedded in QtCreator. The only think that should be changed here is one of the two .pro files. Possibly with post-build calls to MACOS commands...? Or just a post-build instruction in MyApp.pro to copy the dylib in the right place (.app target folder) before application is deployed? I'm really surprised this is not covered silently by QtCreator....
Note: This question suggests to set DYLD_LIBRARY_PATH. But I have no clue hox to do this within the MyApp.pro file nor how it will help upon iOS deployment (as DYLD_LIBRARY_PATH can be set the MAC PATH to the lib, not the iPhone PATH to the lib...)
1) In your library project make sure your dylibs have installname #rpath/mylib.dylib or such. E.g. by adding QMAKE_SONAME_PREFIX = #rpath to your library .pro file.
(You can check by looking at the first line of otool -L /path/to/libmylib.dylib. If the library is a prebuilt 3rdparty one, change it with install_name_tool -id #rpath/libmylib.dylib)
2) add the following to the application .pro file
# link to the lib:
LIBS += -L../mylib -lmylib
# make the app find the libs:
QMAKE_RPATHDIR = #executable_path/Frameworks
# deploy the libs:
mylib.files = $$OUT_PWD/mylib/libmylib.1.dylib
mylib.path = Frameworks
QMAKE_BUNDLE_DATA += mylib
I came up with a workaround for that, in case it could help anyone.
Build your library statically instead of dynamically (replace CONFIG += shared by CONFIG += staticlib
Now, compiler will generate *.a files instead of *.dylib, You must use this extension when linking libraries (replace LIBS += myLib.dylib by LIBS += myLib.a)
If your library was only linked by a program, you are done
If your library, let's call it (A), was used by another library (B), then (B) should not link with it anymore (No LIB flag in B.pro). Only the top level program will link with all your static libraries.
With this approach, I could deploy a program using 15 libraries on an iPhone with QtCreator.