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.
Related
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
I have created a program in Qt using Qt Creator. When I open it, the message appears "The program can't start because Qt5Cored.dll and Qt5widgetsx.dll is missing from your computer. Try reinstalling the program to fix this problem."
copy required libraries from you Qt installation to the directory of executable.
Have you really got a static compiled version of Qt? and are you statically compiling your project?... if so your output executable will be around 30-40mb.... and it won't be asking you for dlls.
However it looks like you have a dynamically linked output, in which case you need to find all the DLLs that your projects uses. You can get these from the folder:
<installpath>\Qt\5.5\mingw492_32\bin for example (different if you use linux / msvc)
Keep running the program and grab each dll it complains about... or use somthing like dependency walker (a free executable you can find online) to help determine which DLLs you need.
You probably need (For windows, using mingw):
Qt5Widgets.dll
Qt5Gui.dll
Qt5Core.dll
libwinpthread-1.dll
libstdc++-6.dll
libgcc_s_dw2-1.dll
Or the debug version in your case which end in "d" e.g.: Qt5Core.dll (release), Qt5Cored.dll (debug). Note versions may be different for your installation version. Copy these files next to your executable. OR include <installpath>\Qt\5.5\mingw492_32\bin in your path.
You need to add all the required dlls
C:\Qt\5.2.1\mingw48_32\bin\
to your project. https://forum.qt.io/topic/50705/solved-qt3d-executable-error-qt5cored-dll-is-missing-from-your-computer/2 should solve your problem.
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.
I am attempting to compile a software that I have built using Qt, ITK, VTK, using mingw32 on Windows 7. I have successfully done this on many computers, but I am having trouble on my laptop.
I made a mistake when I first installed Qt on this machine, in that I installed the "msvc2010" or visual studio verision of Qt. I had VS installed, and this is what it defaulted to, and I did not change it. Realizing my mistake, I uninstalled all traces of this Qt, and installed the Mingw32 version. The exact version I downloaded was: Qt libraries 4.8.3 for Windows (minGW 4.4, 317 MB)
I installed mingw32, installed qt, all nice and dandy, and now I am compiling my software. It builds beautifully, but during the linking stage I get the following nasty error:
mingw32-make[2]: *** No rule to make target 'C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/
lib/QtOpenGL4.dll', needed by 'x.exe'. Stop.
CMakeFiles\Makefile2:62: recipe for target 'CMakeFiles/x.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/x.dir/all] Error 2
Makefile:74: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Where x is the name of my project.
Note the make target: C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll. This is NOT the correct place to look for the DLLs. It is looking at the lib location of my first installation of Qt. The QtSDK folder does not even exist anymore, the new version is under a different folder.
This is sadly also reflected in the link.txt under CMakeFiles that is generated in the build folder by cmake. One of the entries is:
C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\lib\QtGui4.dll
along with many other DLLs.
Clearly, the problem is that Cmake is generating targets for the previous version of Qt.
How can I erase whatever ridiculous cache this is originating from, so that it does not do this? I have reinstalled Cmake, I have reinstalled Qt, I have done everything I can think of. I have verified that the Cmake variable are all pointing to the correct Qt folder (the other one does not exist, so no way we could get to the linking stage if they were incorrect).
Thank you so much.
EDIT:
I get this very pertinent warning, that has the wretched file path in it:
CMake Warning (dev) at CMakeLists.txt:22 (ADD_EXECUTABLE):
Policy CMP0003 should be set before this line. Add code such as
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
as early as possible but after the most recent call to
cmake_minimum_required or cmake_policy(VERSION). This warning appears
because target "x" links to some libraries for which the linker must
search:
comctl32, vfw32, ws2_32, wsock32, -lgdi32, opengl32
and other libraries with known full path:
C:/Qt/4.8.3/lib/libQtGui4.a
C:/ITK/lib/libitksys-4.1.dll.a
C:/VTK/bin/libQVTK.a
C:/QtSDK/Desktop/Qt/4.8.1/msvc2010/lib/QtOpenGL4.dll
CMake is adding directories in the second list to the linker search path in
case they are needed to find libraries from the first list (for backwards
compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable
or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for
more information.
This warning is for project developers. Use -Wno-dev to suppress it.
I added the "NEW" policy, and the warning went away, but I still have the same problem.
The problem turned out to be that I had installed VTK while I had the old Qt (configured for VS2010 installed). When I included VTK's libraries, it also included DLLs from Qt--but it was still pointing to the old Qt.
I reinstalled VTK, and we got past this step.
Try to regenerate cmake files, :
mingw32-make clean
cmake .
Short version: You need to delete your CMakeCache.txt file in your build directory.
Long version: Whenever CMake searches for external libraries/programes etc (eg. by FIND_LIBRARY which is called when searching for Qt, for example), it saves the result in the cache. On subsequent runs, it simply uses the cached value (if any) instead of searching for the libraries again. Therefore, you need to remove these cache entries so that CMake really searches for the libraries again. Simply delete the CMakeCache.txt and start over. If both versions are installed in parallel, make sure that QTDIR environment variable is set correctly and the path includes <QTDIR>/bin, as CMake relies on qmake to find the relevant libraries.
Note: If you don't want to delete the whole cache, deleting the Qt relevant variables should work, too.
cmake -U *QT_* .
should do the trick.
However, deleting the whole cache is the cleanest solution.
I am having the same issue described in this post on the py2app mailing list.
I have a python application that uses a sqlite database. On my machine, which has all the dependencies installed, there are no issues. However, when I bundle the application with py2app, clicking a menu that causes the database to be accessed results in this error:
Database error: Driver not loaded Driver not loaded
For the Windows installer, the files in \Qt\version\plugins\sqldrivers\*.* can be copied to \myApp\sqldrivers\*
The same files on the Mac can be found in /opt/local/share/qt4/plugins/sqldrivers (installed via Macports).
However, copying the sqldrivers directory to my application's Resources or Frameworks directories still results in the same error.
How can I add sqlite support into my application that is built using py2app?
Turns out the pyside recipe does have a way to specify which qt-plugins you need...
options=dict(py2app={
'argv_emulation': True,
'qt_plugins' : "sqldrivers",
}
),
This puts all the sqldrivers into the right directory and setups qt.conf correctly.
have you tried what he said
in this post ?
py2app setup.py usage question
it mentioned
you need to include the sqlalchemy.dialects.sqlite as a package
I managed to get this to work as follows:
After building with py2app, inside the application's Contents directory, make a new plugins directory.
Then copy sqldrivers/libqsqlite.dylib into this plugins directory.
Afterwards, install_name_tool has to be used to change the library links in libqsqlite.dylib to point to the Qt libraries in the application's Frameworks directory rather than the system Qt libraries.