I want to load qt5 psql driver in windows 7.
I've load the library as this way:
qDebug() << QCoreApplication::libraryPaths ();
QString driverName = "QPSQL";
QSqlDatabase::addDatabase(driverName,"A connection to postgres");
And the output shows:
("C:/QT/Qt5.1.0/5.1.0/msvc2010/plugins", "D:/xxx/build-xxx-Desktop_Qt_5_1_0_MSVC2010_32bit-Release/release")
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
And in directory: C:/QT/Qt5.1.0/5.1.0/msvc2010/plugins/, there does have sqldrivers subdirectory and qsqlpsql.dll, qsqlpsqld.dll, qsqlpsqld.pdb in the subdirectory.
I load the psql library successful in ubuntu.
and my .pro file is mainly like this:
QT += core gui sql concurrent
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
unix {
LIBS += -lpython2.7
QMAKE_CXXFLAGS += -std=c++0x
}
win32 {
LIBS += \
C:/Python27/libs/python27.lib
}
I can't find the reason why it failed.
Do I need to add libpqdll.lib in .pro file? But I didn't use LIBS += -lpq in ubuntu?
BTW: I failed to build libpq in windows 7, using visual studio 2010. But this is another problem.
The question may be easy. But I've tried a wholely day.
Most likely it's failing to dynamically link the qsqlpsql.dll file when it invokes LoadLibrary on it after your program requests that driver. LoadLibrary returns the same error code for when the target DLL is missing as for when one of the DLLs the target DLL depends on is missing or cannot be loaded. So Qt quite possibly gets a "library not found" error and assumes "oh, the Pg driver must not be in this Qt build", where in fact it's present and failing to load due to dependency issues, library compatibility problems, etc.
To determine why it's failing to load, you can as Frank Osterfeld suggested use a tool like Dependency Walker (depends.exe). If you're compiling 32-bit code on a 64-bit machine you want to get the 32-bit dependency walker.
It's quite likely to be failing because there's a dependency of qsqlpsql.dll missing - either libpq.dll, or one of the libraries that libpq build requires. Dependency walker will help isolate this. It's also possible you're trying to load a 64-bit libpq.dll in a 32-bit program, or vice versa.
You may also find it informative to run your program with Process Monitor tracing it. This will produce a lot of detail about which files it attempts to open / examine, among other things, and can help track down things like unexpected PATH issues.
If you're still stuck, there's always the option of stepping through with a debugger.
Try copy libmysql.dll into C:\Windows\Systems32
Related
I was informed about the "windeployqt" utility, which should be able collect all Qt/MinGW DLLs that are required to run my Windows Qt application properly. So I gave it a try.
Unfortunately I have noticed that it collects more files then neccessary. I compared the files collected by the windeployqt utility against the ones that are reported by the "Dependency Walker". The files that are really required have been collected properly, but also following files were collected for some reason:
Qt5Svg.dll
iconengines\qsvgicon.dll
imageformats\qdds.dll
imageformats\qgif.dll
imageformats\qicns.dll
imageformats\qico.dll
imageformats\qjp2.dll
imageformats\qjpeg.dll
imageformats\qmng.dll
imageformats\qsvg.dll
imageformats\qtga.dll
imageformats\qtiff.dll
imageformats\qwbmp.dll
imageformats\qwebp.dll
The application just deals with QBus and uses QWidgets to display a simple Window. Therefore I see no reason why these DLLs have been collected.
The fact that a DLL is no listed by Dependency Walker does not mean it is not required.
Dependency Walker will only list DLL required for you exe to be loaded and started by Windows. But other DLLs may be loaded later, while your program is running. This happens in particular when Qt loads plugins like the image format plugins
Because it cannot know beforehand what plugin will be needed, windeployqt deploys all Qt plugins (all which are relevant in regard to the required DLLs).
You can alter the way windeployqt behaves by using command line modifiers like --no-plugins (see windeployqt -help).
You can take a look at Qt for Windows - Deployment in the Qt documentation, in particular the part about Qt Plugins.
windeployqt utility will parse your "EXE" file and determine what packages were used, then it copies needed DLLs accordingly. Make sure to invoke the utility in a configured/set environment.
I use the utility in this way:
Perform release clean build of the project and record build path and "exe" generated. For insrance
c:\myApp\release\ and myApp.exe
Create deployment folder // other than the release build folder//. for instance
c:\myApp\deploy
then invoke the utility from Qt command line utility, as follows:
- Go to all progrmas --> Qt --> Qt command line utility
- cd c:\myApp\deploy
- windeployqt --dir . c:\myApp\release\myApp.exe
I'd like to build application using Gstreamer 1.0 and GTK+-3.0 on Windows 8 (64bit).
I have sucessfully install and build GTK+-3.0, 32 bit version using Dev-C++ and Mingw 32-bit (there is no 64 bit version of GTK+). Everything works perferkt. It also installed pkg-config, I addeded it in %PATH% and it works.
I have installed gstreamer-1.0-devel-x86-1.4.4.msi and gstreamer-1.0-x86-1.4.4.msi from here
1) First problem: it installed itself into I:\gstreamer\ without asking me. I am very unhappy about it, I'd like have it on C:. But its not the biggest problem.
2) pkg-config do not know about gstreamer. I have found in I:\gstreamer\1.0\x86\lib\pkgconfig\ *.pc files, so I looked into gstreamer-1.0.pc and added to my projekt this options:
C compiler:
-I"I:/gstreamer/1.0/x86/include/gstreamer-1.0/"
Linker:
-L"I:/gstreamer/1.0/x86/lib" -lgstreamer-1.0
3) Now the program was compiled, but when I run it, it was not able to find gstreamer-1.0-0.dll. So i tried copy I:\gstreamer\1.0\x86\bin\gstreamer-1.0-0.dll into to the same directory as is my compiled file. Then it was not able to find libwinptread-1.dll. So I copied it also.
Then te program run, but it faild with some error like "cannot find entry point to windows thread ..." (I do not remember it exactly). So I copied ALL dll files from I:\gstreamer\1.0\x86\bin\ and then finally the program run.
But now it is not able to create elements:
source = gst_element_factory_make ("videotestsrc", "source");
//source is null
So, my question is, how to install gstreamer, that my program will find all dll files and will be able to create elements?
installing -- choose "custom install", there you can change the installation path.
for vs you can use *.props (gstreamer\1.0\x86\share\vs\2010\libs)
you need set Environment variable - GST_PLUGIN_SYSTEM_PATH_1_0 to plug-ins. For more details see http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html
I am using TWR-K20D72M and I opened a Sample program which is given in the MQX 4.0.1 Demo examples. When I choose Build tool option as Freescale
the program compiles OK but When I choose Build tool option as GCC It gives me error.The Error is below
error
Description
mingw32-make: *** No rule to make target `C:/Freescale/Freescale_MQX_4_0/lib/twrk20d72m.cw10gcc/debug/bsp/intflash.ld', needed by `explicit-dependencies'.
I read somewhere that The GCC can only work with MQX 4.0.1 and above so I am using MQX 4.0.1 .
Can some suggest me the reason for this error.How I can I remove this error.......
Thanks
You are missing the linker script file for your project intflash.ld.
Normally this file is located on
{mqx_install_dir}\mqx\source\bsp\{your_bsp_name}\gcc_cw
and is copied to
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\debug\bsp
and
{mqx_install_dir}\lib\{your_bsp_name}.cw10gcc\release\bsp
after the build process by the scripts for your bsp, located on
{mqx_install_dir}\mqx\build\bat.
Take a look inside your bsp script and verify that intflash.ld is being copied correctly.
My guess is that you compiled your MQX application before compiling the BSP and PSP. With the release of CodeWarrior 4.6, the solution has gotten a bit easier through the use of .wsd files.
If you look at the FSL_MQX_getting_started.pdf, section 2.4 describes how to find a .wsd file which needs to be dragged into your CodeWarrior Project Explorer. Once this is done new projects will be added to your workspace. Compile the bsp_... and psp_... and any other libs that you require (usb, ethernet etc) which will generate binaries and the intflash.ld file in the correct location.
http://cache.freescale.com/files/soft_dev_tools/doc/support_info/FSL_MQX_Getting_Started.pdf
I am trying to compile the Qt library (I don't need the demos or examples) for 64-bit Windows. There are instructions here but I run into the error described in the comment below it. There doesn't seem to be a reference anywhere for how one might go about doing this process.
I am targetting Microsoft Visual C++ 2010 Express. It looks like I need Perl and the Windows SDK as well - how do I go about this process?
This process is quite tedious and time-consuming - but I will explain each step in detail here for the benefit of others who try to compile Qt in the future.
The first step is to install all of the prerequisites.
ActivePerl, which is used during the configuration process. You will need to restart after installing Perl since it modifies environment variables.
The Windows SDK 7.1 (formerly called the Platform SDK). Be sure to include the x64 libraries when you select the components to install.
Download the Qt source archive from the Qt Downloads page.
Extract the contents of the archive to an easy-to-remember location (like C:\). You need to remember this location later since we will be using it to set some environment variables.
Now open the Windows SDK 7.1 Command Prompt. Begin by setting the environment to 32-bit release mode (we need to build some of the tools as 32-bit applications):
setenv /release /x86
Set the following environment variables (example below assumes you extracted to C:\):
set QTDIR=C:\qt-everywhere-opensource-src-4.8.0
set PATH=%PATH%;%QTDIR%\bin
Now run cd %QTDIR% and specify the configuration options - example is included below:
configure -release -opensource -qt-zlib -qt-libpng -qt-libmng -qt-libtiff
-qt-libjpeg -qt-style-windowsxp -qt-style-windowsvista -platform
win32-msvc2010
Once the configuration process is complete, cd to the src directory and run:
qmake
nmake
This process may take a considerable amount of time, so now would be a good time to take a break and answer some questions here on Stack Overflow :)
The tools are now built and you need to compile Qt as a 64-bit library. Enter the following command:
setenv /x64
You will need to set the environment variables from step 5 again. Enter those commands now.
Run cd %QTDIR% and then rerun the configure command being sure to specify one additional option:
configure -release -opensource -qt-zlib -qt-libpng -qt-libmng -qt-libtiff
-qt-libjpeg -qt-style-windowsxp -qt-style-windowsvista -platform
win32-msvc2010 -no-qmake
The -no-qmake option is very important - it indicates that we want to skip the compilation of the qmake.exe program because we want to keep the 32-bit version.
Now things get really complicated here because of some dependency problems. The tools (like moc) that Qt needs to build the core library and some of the other components are listed as dependencies in the src.pro file. This means that the compiler will attempt to build them as 64-bit applications and then try to run them - which will of course fail on a 32-bit system. So what we need to do is edit src.pro and remove those dependencies ourselves. Scroll down near line 85 and look for a line that begins with:
!wince*:!ordered:!symbian-abld:!symbian-sbsv2 {
Each subsequent line in the section lists a sub-target and its dependencies. What you want to do now is remove all dependencies that begin with src_tools_. For example:
src_gui.depends = src_corelib src_tools_uic
Becomes:
src_gui.depends = src_corelib
There might be a better way of doing this, but I haven't figured it out yet :)
Now we cd into the src directory once again and run the following command
nmake sub-winmain sub-corelib sub-xml sub-network sub-sql sub-testlib
sub-gui sub-qt3support sub-activeqt sub-opengl sub-xmlpatterns sub-phonon
sub-multimedia sub-svg sub-script sub-declarative sub-webkit
sub-scripttools sub-plugins sub-imports
This builds only the Qt libraries and skips the tool dependencies. Note that this too may take a considerable amount of time.
You should now have 64-bit libraries in the lib folder that you can link against in your 64-bit Qt applications.
Edit: it turns out that even this wasn't enough since I still ran into some problems when linking the QtWebKit4.dll library (something about unresolved symbols). It turns out that someone else has already found the solution and you need to change QMAKE_HOST.arch to QMAKE_TARGET.arch in WebCore.pro.
Also, the above options will build QNetwork4.dll without OpenSSL support (you won't be able to access sites over HTTPS - even in a QWebView). This, thankfully isn't too hard to fix. Download and build OpenSSL for Win64 and append the options below to the command in step #9:
-openssl -I C:\OpenSSL\inc32 -L C:\OpenSSL\out32dll
(You'll have to change the paths if you installed OpenSSL somewhere other than C:\OpenSSL.)
Further edit: to save the trouble of doing this yourself, I have uploaded the compiled libraries here:
http://www.box.com/s/9710cbb278ef4890a7b5
As I mentioned in the comments to George Edison's answer, there is a bug in the Microsoft Visual C++ compiler that comes with the Windows SDK 7.1. For more information on this, see QTBUG-11445 and QTBUG-19175.
I have compiled the Qt 4.8.2 64-bit binaries following George's instructions, including the OpenSSH library. In addition, I applied Microsoft's hotfix to fix the compiler bug.
For your convenience, I have made the resulting 64-bit libraries available for download from here: https://www.box.com/s/8948c60c3cdd743ef83b
I'm trying to deploy my simple Qt project like a hello world.
I build it successfully and can also execute it on Qt-Creator. However, I can't execute the binary directly in the release folder due to some shared library errors.
So I just copy some essential librarys to the release folder such as qtcore.dll and qtgui.dll, but I can't still execute it.
How can I deploy my simple Qt project? Is there an another step to deploy it?
You also need to deploy the MINGW runtime dll (mingwm10.dll). This file is located in your Qt\2009.5\mingw\bin directory.
Also pay attention to whether your application is compiled in debug mode or release mode. I just made the test with an hello world type application and Qt Creator. In the debug folders, I copied libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll and QtGuid4.dll and it works.
Pay attention to the d in dll names, which stands for debug: QtCore d 4.dll.
See Qt 4.6: Deploying an Application in Windows.
For Qt 5, check this page.
If you don't want to have dependencies with qt/mingw dlls you should compile qt statically as explain here: http://qt.nokia.com/doc/4.6/deployment-windows.html#static-linking.
You may also use static linking, just add this line into the .pro file:
QMAKE_LFLAGS += -static-libgcc
I found the solution here and successfully tested on WinXP with QT creator 2.2.0
Try running dependency walker on it (http://dependencywalker.com/) to see which dlls are missing?
Generally, you won't need to move those Qt libraries into your local folder since the Qt installation should've added those libraries into your path.
One possibility is that you built debug, and the Qt debug dlls are named differently
copy all the qt dlls to your windows directory directly "C:\Windows\" and there will be no qt dll error
100% working and simple
nb: do not create a qt dll folder in your windows directory post them as they are