How to open Command Line application built from Xcode outside of Xcode? - c++

I have a console application project which uses my own framework. When I build and run the application from Xcode it's executed successfully. However when I try to open the executable from terminal outside of Xcode I get the following error:
dyld: Library not loaded: #rpath/Logic.framework/Versions/A/Logic
Referenced from: /Users/semyon/Library/Developer/Xcode/DerivedData/VocalTrainer-fyzwymbxfxusrqejhssrjfeovnqg/Build/Products/Debug/./MvxGenerator
Reason: image not found
zsh: abort ./MvxGenerator
The question is: How to deliver the release build of my command line application which uses a framework?

You need to install the framework/ dynamic library at #executable_path/../Resources/lib folder. If you share a .app bundle, just copy it in Contents/MacOS/Resources/lib folder. If a binary, make sure your installer keeps the framework at the right place.
You may want to inspect other open source app bundles which do this:
Cmake
Visual Studio Code
etc

Related

yaml-cpp issue: InvalidNode#YAML##QEAA#AEBV?$basic_string#DU?... not found in DLL

I am facing a runtime issue while running a C++ application in windows that links to the yaml-cpp library (yaml-cpp.lib).
The yaml-cpp has been installed using vcpkg.
The error has been pasted below. Please let me know if you have a hint for solving this issue.
The package dependencies have been configured using CMakeLists.txt and built using ament_cmake. The Visual studio project created in the build folder is able to run without any problem, but this issue occurs only while running the executable using ros2 run in the terminal.
Error Message in pop up window:
radf_execution.exe - Entry point not found The procedure entry
point
"??0InvalidNode#YAML##QEAA#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z"
in the DLL "D:
02_Ws\ros2_ws\install\radf_execution\lib\radf_execution\radf_execution.exe"
was not found.

CMake: "Linked Library" error (0xc0000135) when attempting to run on Jenkins Build Machine

CMake relative newbie.
I currently have a Cross-compiling (Windows 10/CentOS) project where I have added a post-build hook to automatically run Google Test, using this method.
Everything works great in Windows and Linux, it correctly builds then executes the Google Test Executable. However, on our Window's server Jenkin's build system, I keep getting the following:
CMake Error at <path to cmake>/cmake-3.17/Modules/GoogleTestAddTests.cmake:40 (message):
Error running test executable.
Path: '<path to project root>/build/extern/<submodule>/tests/Debug/<project>.test.exe'
Result: Exit code 0xc0000135
Doing research, the error code seems to be related to the exe missing a dynamically linked library. However, I can't figure out if it is the main project library (call it project.lib) is missing, or something else. Any help/experience on debugging this would be appreciated.
Just to give an answer:
It turned out the dll libraries for Windows .Net was not installed. After installing them/making sure they were on the path, the problem resolved itself.
I had the same problem with Catch2 on an integration machine using Azure DevOps.
The integration report displays:
CMake Error at C:/Projets/<PROJECT>/application/testing/Catch2/extras/CatchAddTests.cmake:45 (message):
Error running test executable
'C:/Projets/<PROJECT>/application/build/testing/Process/Debug/testing_Process.exe':
Result: Exit code 0xc0000135
Output:
The root cause: the testing_Process.exe binary is missing a required .dll library of external SDK.
The solution: Add the .dll required to the system path of the integration machine.

Running Qt app on different computers

I've just finished my first Qt program. I compiled it with MinGW 32bit compiler.
On my computer I have installed all necessary dll files when I was installing Qt.
After Profile/Debug/Release I can successfully run the app on my computer.
but..
On second computer (also Windows 10) I'm getting errors about missing dll files.
Qtguid.dll, qtwidgets and many more. I tried to put some missing dll files to the program directory. New errors occurred, like 0xc00007b.
What can I do to solve these problems with dll files? What can I do to make this app be able to run on different PCs?
If you are compiling your app under Windows, 32bit version it's completly compatible with x64 bits version. There is no problem running the app in Windows 7 or 10 if you are using only Qt dlls.
I recommend you to check Qt Deployment Documentation and use windeployqt to get all required dll files. Basically:
Compile your app in Release mode.
Create a new folder and copy your generated exe file to this folder.
Acces to the Qt Mingw32 (or MSVC) command promp and go to the folder and run:
cd C:/myFolder
windeployqt .
Windeployqt will copy all required files in this folder. When the process finished, just run the app. Compress the folder in rar or zip and test it in other computers.
If the problem still happens, use DependencyWalker to check the required dlls. Copy the required files in the folder.
When all works fine, you can use InnoSetup to create an installer.

Qt5 cannot find platform plugins Mac OS X

I am trying to deploy a Qt program on Mac according to this link. After going through with otool -L on my executable and all of the libraries that it depends on, which I copied into the application bundle, I get this error in QtCreator's application output when I try to run it.
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
Reinstalling the application may fix this problem.
The program has unexpectedly finished.
I've tried copying the qt platform plugins libqcocoa.dylib and changing the plugins directory in qt.conf, according to this, but it still fails.
Also worth pointing out, I first tried to use qt's macdeployqt tool, but it fails with this message, despite being the first time I run it on the executable:
ERROR: Could not find bundle binary for "MyProgram.app/Contents/MacOS/MyProgram"
ERROR: "otool: can't open file: (No such file or directory)"
WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "MyProgram.app/Contents/MacOS/MyProgram"
WARNING: Perhaps macdeployqt was already used on "MyProgram.app/Contents/MacOS/MyProgram" ?
WARNING: If so, you will need to rebuild "MyProgram.app/Contents/MacOS/MyProgram" before trying again.
ERROR: Could not find bundle binary for "MyProgram.app/Contents/MacOS/MyProgram"
ERROR: file copy failed from "/Developer/Applications/Qt/plugins/platforms/libqcocoa.dylib"
ERROR: to "MyProgram.app/Contents/MacOS/MyProgram/Contents/PlugIns/platforms/libqcocoa.dylib"
ERROR: file copy failed from "/Developer/Applications/Qt/plugins/printsupport/libcocoaprintersupport.dylib"
ERROR: to "MyProgram.app/Contents/MacOS/GraphiteMiniEditor/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib"
Re macdeployqt fails: it seems like, for the argument to macdeployqt you are passing the path to the executable instead of the path to the bundle. I.e. just pass .../MyProgram.app instead of .../MyProgram.app/Contents/MacOS/MyProgram.
(But I am also unable to get it find libqcocoa, in a sandboxed app. I may resort to linking that statically into my app.)
To give Kamil Klimek's solution some more attention (It solved the problem for me):
I had the same problem when I installed QtCreator (Qt 5.x) with the offline installer, but apparently also had Qt (4.x) installed through Homebrew (probably pulled in as a dependency). Compiling the code with 5.x, and deploying it with the 4.x macdeployqt script doesn't work.
So, make sure that e.g.:
which macdeployqt
calls macdeployqt from the same Qt version / path used to compile the code.
I had this error with OS X Lion, using Qt 5.4.2. When I installed the Xcode command line utilities, then the error went away and macdeployqt worked.

Running in the Terminal a build made in XCode, how?

Im creating a project in Xcode using OpenCV as a framework. It works great with the Build&Run option from Xcode, but now I need to run it in the Terminal and it gives me this error:
dyld: Library not loaded: #executable_path/../Frameworks/OpenCV.framework/Versions/A/OpenCV
Referenced from: /Users/Victor/Documents/PFC/src/opencv/blob/build/Release/./test3
Reason: image not found
Trace/BPT trap
I look for the build and just execute it with ./
So, any clue?
You need to run it from the build directory rather than the Release directory (assuming Frameworks is a directory in blob)