Qt Project Dyld Error Setting rpath - macos

I have a Qt project and I need to include some libraries
I have this in my .pro file:
QT += webengine
I can build and run it fine on my Mac but if I try to send the .app to someone else and they run it, there is this error:
Dyld Error Message:
Library not loaded: #rpath/QtWebEngine.framework/Versions/5/QtWebEngine
Referenced from: /path/myApp.app/Contents/MacOS/myApp
Reason: image not found
I have the QtWebEngine.framework and its corresponding QtWebEngine.framework.dSYM file in my directory:
Users/myUsername/Qt/5.11.0/clang_64/lib
I also have the .framework in my directory:
Library/Frameworks
In the editor, I looked at Projects > Desktop Qt 5.11.0 clang 64bit2 > Run > Run Environment, and I found that the DYLD_FRAMEWORK_PATH points to where the .framework file is located. Same for DYLD_LIBRARY_PATH.
This is confusing me because it works on my Mac but not on others. It also seems like the paths are all in order. I have tried using other suggestions on this website but they do not seem to work for me or maybe I just did them wrong. Maybe someone could help me?
Update:
If I need to add the .pak resource files to my deployment, how can I do this?

Related

Can't compile App from Titanium Appcelerator with iOS OpenCV Module

I have an issue that is going on for over a month and I can't find any solution for it.
I created an Appcelerator Titanium Module, which uses the OpenCV framework.
I tried literally everything I found on the internet to make it work, but no sucess.
The module compiles, but it crashes when building the App that uses it.
To dig deep in the problem, I compile the App via CLI using appc run -p ios -l trace to see the whole thing. This is what I get:
[TRACE] ld: framework not found opencv2 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
This happens if I declare the framework in the module.xconfig file, like this:
OTHER_LDFLAGS=$(inherited) -framework opencv2
If I don't declare it in the file, I get:
[TRACE] symbols not found for architecture x86_64 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
Well, the opencv2.framework file is inside the /ios folder in the module.
This is what I tried so far, to put the OpenCV Framework in the project:
OpenCV Official Example for XCode
Compiling it from scratch and then adding to the Project
brew install opencv and then adding it to the project
I configured Framework Search Paths like this:
$(inherited) $(PROJECT_DIR) $(SRCROOT)
Header Search Paths like this:
$(inherited) "$(TITANIUM_SDK)/iphone/include" /usr/local/Cellar/opencv/4.4.0/include (this last one, when installed by brew CLI command.
The Other Linker Flags, is configured like this:
This configuration I got from this tutorial: OpenCV on XCode
And finally, I tried adding the .dylib files from the source of the OpenCV Framework in the project by right-clicking the project's name and Add Files.
So, I tried everything I could find to solve it, but I can't get it to work.
Sorry for the long question, but I am completly out of ideas on how to make this work.
Please, help me!
First of all, the opencv2.framework is copied automatically to the XCode /ios folder (if you selected Copy Files if Needed). BUT, Appcelerator needs 3rd party frameworks to be put on /ios/platform folder. So, I moved it there.
Secondly I added -lz to the Other Linker Flags in Build Settings.
This solved the problem. I must thank the team and developers from TiSlack (An Appcelerator platform community), which helped me through this. Michael and Hans, Thanks!
Here is a video that helped me install OpenCV4 on my Macbook Pro Mojave 10.14.6. I tried installing OpenCV using another video and it led me to getting a linker error that was similar to yours.
Basically, the problem was the path I specified as for my /lib and /include folders.
https://www.youtube.com/watch?edufilter=NULL&v=HxNZEa7Slyk

Could not find or load qt plugin windows

After having enough in searching and reading peoples questions that had the same problem as i have and trying allot of solutions that doesn't seems to help, I'm posting my question.
I want to run my project- qt application, it ran well when i built it on qt4.8.1 32bit and 5.1.1 64bit. now i want to run it on qt5.3.0 32 bit. i installed qt open source with the following configuration:
qt 5.3.0 msvc2010_opengl 32bit.
Since my projects is using qt solutions- qt single application and qt service, i downloaded the packeges, built it in the new environment and placed them in qt/qt5.3.0/5.3/bin and qt/qt5.3.0/5.3/lib.
(I mention this last detail because a simpler qt project that doesn't use these dlls- service and single application runs well in my environment).
Well, when I run my application from qt it doesn't run. When i run the exe file from the release folder i get the following error:
This application failed to start because it could not find or load the qt platform plugin "windows". reinstalling the application may fix this problem.
I tried all creative ideas:
note: I see that automatically the build arainged the release folder with the folowing struck:
plugin folder with all plugins in it.
platform folder with the hole list of platforms: qwindows.dll, qminimal.dll...
and also put straightly the dlls: qwindows.dll, qwindowsd.dll
libEGL.dll
libEGLd.dll
qt.conf with the data:
[Paths]
Plugins=C:...\build-____-Desktop_Qt_5_3_0_MSVC2010_OpenGL_32bit-Release\release\plugins
I used the dependency walker that told me that the IEShims.dll is missind, so I brought it to the release folder from: C:\Program Files (x86)\Internet Explorer.
Now the dependency walker tells me:
Warning: At least one module has an unresolved import due to a
missing export function in a delay-load dependent module.
I see that the Qt5core.dll->link checksum member in the dependency is marked with red, and also I see it takes it from:
C:\Qt\Qt5.3.0\Tools\QtCreator\bin
so I bring to the release folder the Qt5Core.dll from:
C:\Qt\Qt5.3.0\5.3\msvc2010_opengl\bin. then I get the following message:
the procedure entry point
?bytearrayToDouble#QLocalePrivate##SANPBDPA_N1#Z could not be located
in the dynamic link library
c:/Qt/Qt5.3.0/Tools/QtCreator/bin/Qt5Gui.dll
so maybe its wrong to do so.
what else can i do???

xCode and ImageMagick not working? Linking to project bundle

I made project with ImageMagick included. I installed it through macPorts, linked libraries and headers to my project. Everything worked. But when I try to launch my builded app on other computer, where ImageMagick is not installed, it doesn't even opens my app. Says that Os X version is incompatible. If I install ImageMagick to that computer, then app works OK. What should I do to make it working on computers where users does't have ImageMagick? I guess I have somehow to include headers and libraries to my project bundle. But how to do it in correct way to get working? I tried to copy headers and libraries to my project's bundle but then when I try to build it it says that Magick++.h is not found. Can somebody help me?
I added ImageMagick files from where macports installed it (/opt/local/lib/ and /opt/local/include) to my created folder named ImageMagick, then moved that folder to my project and added ImageMagick/** to Library Search Paths and Header Search Paths. Then removed ImageMagick through macports. Project builds successfully, but doesn't runs. It shows error in console:
dyld: Library not loaded: /opt/local/lib/libMagick++.5.dylib
Referenced from: /Users/development/Library/Developer/Xcode/DerivedData/OGL-cahltqazoqxhrthkxztsqyvvodge/Build/Products/Debug/OGL.app/Contents/MacOS/OGL
Reason: image not found
(lldb)
Libs added to Linked Frameworks and Libraries list is in my app's folder and added to my project. Why it searches for it in /opt/local/lib?

Deploying Qt Frameworks with Mac app and usage of otool

I have a problem deploying Qt frameworks with my Mac app, and I hope some will have a clue why I get this error, when I run the app on clean Mac, i.e. not a developer Mac.
OS: 10.7 .2 and using XCode
Error msg:
Library not loaded: #loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from:/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Clearly something is wrong since the QtXml is referenced from /../Frameworks/../Frameworks, which doesn’t exists.
This is the set up: I have a dylib that uses QtCore and QtXml (not by my choosing, but for now I need those two frameworks), the dylib is used in a NSBundle, which is loaded by the main app, the bundle is located in the resource folder. The dylib is moved by Copy Files Build Phase to the folder Contents/Frameworks and with otool the install_name is set to (as stated by http://doc.qt.digia.com/4.3/deployment-mac.html):
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
#loader_path/../Frameworks/QtXml.framework/Versions/4/QtXml
then the Qt frameworks are moved to Contents/Frameworks and the install_name of the is set to:
#executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
and for the QtXml
#executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml
with reference to QtCore:
#executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Now when I run the app on the developer mac it clearly works since Qt is installed, but when moved to a clean mac I get the error msg, readable in the Console app.
I’ve tried to change the executable_path to loader_path, but this didn’t work.
I have no idea what I’m doing wrong or why it won't for, and have not been able to find anything on Google, of course I could be looking at the wrong places. Any ideas how to fix this problem?
This is the entire error message:
MainApp: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle
“Library” couldn’t be loaded because it is damaged or missing
necessary resources."
(dlopen_preflight(/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/
Contents/MacOS/Library): Library not loaded:
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from: /Users/ someUser /Downloads/
MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Reason: image not found) UserInfo=0x107c5d5d0
{NSLocalizedFailureReason=The bundle is damaged or missing necessary
resources., NSLocalizedRecoverySuggestion=Try reinstalling the
bundle.,
NSFilePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library,
NSDebugDescription=dlopen_preflight(/Users/someUser
/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/Library):
Library not loaded:
#loader_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
Referenced from:
/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle/Contents/MacOS/../Frameworks/../Frameworks/QtXml.framework/Versions/4/QtXml
Reason: image not found,
NSBundlePath=/Users/someUser/Downloads/MainApp.app/Contents/Resources/Lib/Library.bundle,
NSLocalizedDescription=The bundle “Library” couldn’t be loaded because
it is damaged or missing necessary resources.}
On the development mac everything works because the Qt libraries are installed. On any mac you ship the app to, though, this likely won't be the case. The Qt suite comes with a tool called macdeployqt to fix this. So in a terminal, after you've compiled your application, do something like:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app
Note that it can also be used to create a .dmg file for shipping everything together:
# cd my-cool-app-Desktop
# macdeployqt my-cool-app.app -dmg
Once you've done that, the .app directory or .dmg file can be given to someone else without Qt installed to use and run as they normally would.
The one caveat is that the next time you try to run it on your developer machine, it may complain about multiple shared libraries installed. So once you've copied it else where in order to distribute it, remove the entire .app directory and let qtcreator (or whatever) rebuild it.
UPDATE
As stated compiling QT to static libs is the way to go. With the release of Mavericks (10.9) we need to codesign frameworks as well (http://furbo.org/2013/10/17/code-signing-and-mavericks/), and with QT4.8.5 there are some issues (https://bugreports.qt-project.org/browse/QTBUG-32896). Even with suggested fixes I still had some issues when running the app on a clean machine. Therefore, I ended up with compiling Qt5.2 to staticlibs, link them in the app, and codesign them.
OLD
Problem sovled, I moved the Qt-frameworks into the app bundle in Contents/Frameworks and with otool set the path to #executable_path/../Frameworks, i.e. moved it out of my library bundle. Yes the solution is simple, but I'm still not sure why the library executable couldn't find the frameworks when using #loader_path.
The best solution would probably be to use a static library and not wrap it in a bundle...you learn everyday ;)

Setting dylib paths as a XCode build step

I have a Cocoa application as XCode project that has several supplementary bits of functionality as dylib targets.
When XCode builds the project, it places all the build outputs in a single folder: The .app bundle and the dylib files. And when executed from the XCode debugger, the .app launches.
I can't however launch the application from finder.
How do I setup XCode to 'deploy' the app in a standalone state? I have found that I can use ld on the actual app binary to contain a relative path to the dylibs: #executable_path/../../mylib.dylib
Running a script after each build seems wrong: there must be some way (that Im totally missing) to do this easily from inside XCode - it must be a common issue surely?
It looks like that XCode supports having #executable_path, #loader_path and #rpath used in the Target Info > Build > Linking > Dynamic Library Install Name setting (LD_DYLIB_INSTALL_NAME) setting.
The help text says: "Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will record that path as the way dyld should locate this library"
This seems very promising, but usability is a problem if I need to link dylibs in multiple paths against a common library - the relative path is going to be different each time.
Running my testapp from finder, I get the following (relevant) error text
Dyld Error Message:
Library not loaded: #executable_path/../../util.dylib
Referenced from: /Volumes/data/Code/TestApp/build/Debug/TestApp.app/Contents/MacOS/TestApp
Reason: image not found
util.dylib is in /Volumes/data/Code/TestApp/build/Debug/ so I am confused :/
You should use a Copy Files build phase to copy the dylib to the app's bundle when building the app. You'll want to copy it to Frameworks. You can then set the install path to #executable_path/../Frameworks/mylib.dylib.

Resources