Why do I receive "File corrupted!" error after changing library ID from #rpath to #executable_path? - dynamic-linking

I use Qt 5.12 with XCode 10 for building my desktop application. I've received a .dylib from a 3rd party in order to integrate it into my application. I've modified my .pro file to add the library in the LIBS variable.
If I leave the library id as #rpath/test.dylib (compatibility version 0.0.0, current version 0.0.0) everything works fine.
If I use install_name_tool and change the library id to #executable_path/../Frameworks/test.dylib, I get a weird error after starting my app:
File corrupted! This program has been manipulated and maybe
it's infected by a Virus or cracked. This file won't work anymore.
Note: I am sure that the library is available at #executable_path/../Frameworks so that is not the issue.

Related

Where does the Qt sqlite plugin look for extension libraries

I have made the appropriate modification as found in this thread to enable the Qt sqlite plugin to load extensions. However, when I run SELECT load_extension('spatialite_mod'), I now get the error The specified module could not be found
On a Windows Qt installation, where do I need to put the spatialite_mod.dll file so that it can be found a runtime? I have already tried putting it in the binary directory without any success.
This turned out to be a multi-part problem.
The answer to the original question is that Qt looks for the libraries in the working directory (QDir::currentPath()) and in the Windows PATH.
Part 1:
On Windows, the specified module could not be found error also can mean that one of mod_spatialite.dll dependencies was not found. In my case, I had forgotten to move these dependencies to the same directory as mod_spatialite.dll. They include:
libgcc_s_dw2-1.dll
libstdc++-6.dll
libsqlite3-0.dll
libxml2-2.dll
zlib1.dll
libfreexl-1.dll
libgeos_c-1.dll
libgeos-3-5-0.dll
libiconv-2.dll
liblzma-5.cll
libproj-9.dll
Part 2:
The libgcc_s_dw2-1.dll and libstdc++-6.dll libraries shipped with libspatialite do not work with Windows 10. Read more about this here and here. They would crash the program when loaded. The fix for me was to grab the same libraries from my Qt installation at C:\Qt\5.11.3\mingw53_32.

Cannot find c:\Users\qt\work\install\lib\Qt5Widgetsd.lib when compiling QtWebEngine examples

I downloaded Qt5.6 VS2013 32bit and try to run the official example of QtWebEngine.
I just followed the instruction but
When linking it gives out an error of
LNK1104 file not found c:\Users\qt\work\install\lib\Qt5Widgetsd.lib.
However, I have no idea of where this path c:\Users\qt\work\install\lib\ comes from.
I did text search in all directories of example folder and no hits other than generated files(makefiles and pdbs).
I also checked system environment variables but no hits.
Furthermore, I checked Qt Creator'r Projects panel and its Build Environment and still no hits.
Did I miss something?
P.S. this error was given out by linking DemoBrowser example of QtWebEngineWidgets pro
The link is generated by qmake when it generates the build scrip from the qt project file (*.pro). It is based from the qmake application path that is generaly installed together with the libraries (check you qt kit setup to change it if needed: Jst browse to qmake.exe application).
Then try regenerate the build script. It should fix the issue.
You may also have issue with installation not being in debug mode; you are trying to use Qt5Widgetsd.lib library instead of the non-debug one Qt5Widgets.lib

Qt compile error bits/c++config.h not found

I just installed Qt, Qt creator and g++ on the latest version of Mint, and attempted to compile the default hello world project. After configuring a compiler kit I get the following error:
bits/c++config.h: No such file or directiry
/usr/include/c++/4.7/utility
No surprise there is no such file at that location. It appears this is some sort of config file where you specify what architecture you're compiling for.
What package do I install, or how do I write or generate this config file?
c++config.h is not in /usr/include, but rather in an architechture-dependent path. What you need is one of the libstdc++ development packages. You have not specified your platform details but my guess is that what you need is libstdc++6-4.7-dev as the error message refers to 4.7. See full list of packages containing c++config.h under Ubuntu and Ubuntu-likes here.
I don't know of a specific package search for Mint but the Ubuntu one has hit the nail on the head for me.
edit: ah drat, I only noticed this was 8 months old immediately after I posted the answer. Is this bad?

Qt generates multiple .so files - which one to use?

I am learning about shared objects (.so) / dynamic link libraries (.dll). Since I'm on Linux only .so files are relevant. Anyway, when I compile a shared library, I get multiple .so files - most of which are only links. Here is a screenshot:
Then I created another Qt console application project to test this SO. I had set up all the header files, copied every .so file from previous screenshot to this new project and added
LIBS += "libAritmeticnoKodiranjeDLL.so"
to project settings. If I compile the project it goes through OK. But when running my test app I get this error:
./DLLTester: error while loading shared libraries: libAritmeticnoKodiranjeDLL.so.1: cannot open shared object file: No such file or directory
Where is the problem and why do I get so many .so files?
Just do:
LIBS += -lAritmeticnoKodiranjeDLL
The specifics of the libraries prefix ("lib") and suffix (".so") will be taken care of by the linker.
Note how all except one are just symbolic links, and the actual file is the one with most precise version. This is to support different versions of the library, the symbolic links determine which exact version is used when version is not fully defined. If you are installing libs to system library folders, this is kind of important, but if you are just distributing one non-shared version along with your application, then you can use the name without version number.
When running application with custom libraries, you need to add the directory to LD_LIBRARY_PATH environment variable, so runtime linker finds them. See https://stackoverflow.com/search?q=LD_LIBRARY_PATH . For troubleshooting, you can run ldd yourprogram to see what shared libraries are actually loaded, and echo $LD_LIBRARY_PATH will let you make sure LD_LIBRARY_PATH is what you think it is.
I can definitely confirm from my current experience that QtCreator 4.0.3 with Qt 5.7 under Linux (Ubuntu 16.04) when building a shared library (using TEMPLATE = lib) then resulting target is libName.so (when CONFIG += unversioned_libname) or libNAME.so.1.0.0 (when CONFIG unchanged). However an application built with the very same environment links correctly against that library (LIBS += -Lfolder -lNAME) during linking but unfortunately during run-time it requests for linName.so.1 because "Application Output" says error while loading shared libraries: libNAME.so.1: cannot open shared object file: No such file or directory (I can see libName.so.1 in the generated binary of the app but NOWHERE else - not in Make files). I have spent 2 working days to figure this all out. The only way is to manually change the name of generated .so file to fit what application requests.

Imagemagick Linking to QT and mingw32-make: *** [debug] Error 2

I created an application using Imagemagick library with Qt on Mac.
Now that I want to deploy the application for windows:
I installed the imagemagick library
on my pc,
I installed the SDK version of QT 4.7
I added my include and lib paths
And when I go run the application I'm getting errors that I think they are related to mingw32.
here are the build issues:
and here is the compile output:
Can someone Identify the error ?
What do I have to do to deploy the application for windows?
I also tried to use a Mingw32 version of my library but again, It didnt work:
When I put -lmagick after the lib it says file lmagick cannot ne found
and when I try to build unticking the shadow build checkbox in the build settings, it give me the errors in the first screenshoot. Thank you
See the answer to this question.

Resources