I think the "problem" is a missing PostgreSQL dll, not the Qt driver. The driver also needs the dll.
I think the "problem" is a missing PostgreSQL dll, not the Qt driver. The driver also needs the dll.
Stampede spake saying:
and WilliamSpiderWeb wrote earlier:The thing is that this plugin is probably already built ( qsqlpsql.dll exisits in his Qt installation ).
and gave us error messages from the GNU ld, i.e. the MingW compiler suite.I got the lib from a friend of mine. He used it to communicate to a postgres db with a Visual C++ project (without MFC).
It took this to mean that his friend built the plugin with MSVC, and that WilliamSpiderWeb is using MingW. This plugin will not load into a MingW-built program for a variety of reasons. That's why I suggested building the plugin. Perhaps someone else can tell us if PostgreSQL would also have to built with MingW or if the downloadable binaries are sufficient?
To address one of the plugin build issues...
nmake is the make utility from the MSVC compiler suite. You are using the MingW compiler bundled in the Qt SDK. The equivalent command would be:
ChrisW67, you are probably right, I just assumed that the qt plugin was built during Qt installation.
I've just downloaded PostgreSQL from here : link (Binaries from installer version 8.4.7-1 for Windows), and it took me 30 sec. to build the plugin (g++ 4.5.2):
Just make sure that path in INCLUDEPATH and LIBS is correct.Qt Code:
cd C:\Qt\src\plugins\sqldrivers\psql qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro makeTo copy to clipboard, switch view to plain text mode
I'm not sure what I am doing wrong.
I started cmd, then moved to the directory "..\src\plugin\sqldrivers\psql".
The psql-folder was just created by me.
Now I typed the following command.
The error message I get isQt Code:
c:\qt\2010.05\qt\qmake\qmake.exe "INCLUDEPATH+=C:\psql9\include" "LIBS+=C:\psql9\lib\libpg.lib" psql.proTo copy to clipboard, switch view to plain text mode
When I create an empty textfile or copy an existing *.pro file to the directory "...sqldrivers\psql" I get the following error messageCannot find file: psql.pro
QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: psql.pro
Am I on the completly wrong way?
I want my qt App communicate with a postgresql database.
Chris and stampede told me I have to build a psql plugin for qt.
That's what I'm actually trying to do.
Qt Code:
cd C:\Qt\src\plugins\sqldrivers\psql qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro makeTo copy to clipboard, switch view to plain text mode
If I just type qmake, my pc cannot find the command. That's why I typed the whole path of qmake.exe.
And postgres is installed in C:\psql9 on my computer.
And as you can read in my last reply, it doesn't work on my computer.
And you intend to do it by compiling a project from a directory that doesn't contain any source (nor other project) files? You expect some magic to happen that your compiler knows how to build that plugin from an empty directory?
You shouldn't be creating any directories. Qt sources should contain a psql directory inside src/plugins/imageformats and there should be a bunch of files there including a README file containing requirements and instructions for building the plugin.The psql-folder was just created by me.
I expected no kind of magic. But as you know that thread is posted in -Newbie- Forum. It's my first qt project and noone tells you what qmake and nmake are supposed to do. So I could be that qmake creates the psql.pro...
Anyway, now I know that it works in a different way.
I think my problem was I had installed the "qt sdk 2010.05" and the "qt 4.7.2". And in one folder the folder "...\qt\src\plugins\sqldrivers\psql" exists and in one not.
Now I've found the psql-project and the qmake-command seems to work.
But when I use mingw32-make.exe I get errors again.
The German expression in the cmd-output means:C:/qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory 'C:/Qt/2010.05/qt/src/plugins/sqldrivers/psql'
g++ -c -g -frtti -fexeptions -mthreads - Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include" -I"c:\psql9\include" -I"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o main.cpp
Der Befehl "g++" ist entweder falsch geschrieben oder konnte nicht gefunden werden
mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/2010.05/qt/src/plugins/sqldrivers/psql'
mingw32-make: *** [debug-all] Error 2
I haven't chosen something with g++.The command "g++" is wrong spelled or does not exist
Please help me again.
If you look at the description of the forum you'll notice it says "Newbie to Qt", not "Newbie to programming".
The docs for Qt and Visual Studio should tell you that. You can't expect to have zero knowledge about something and immediately use it to its full potential. Maybe your first Qt project should be something simpler than accessing databases.It's my first qt project and noone tells you what qmake and nmake are supposed to do.
Please learn to use a compiler.But when I use mingw32-make.exe I get errors again.
The German expression in the cmd-output means:
I haven't chosen something with g++.
Please help me again.
That's not my first programming project at all.
Your post was not that helpful.
I don't know why you are going to do verbal attacks against me.
I'm not doing any verbal attacks against you. I'm just irritated with "I'm a newbie, be nice and fuzzy and do everything for me" attitude. If you use a tool, any tool, learn what it does before you use it for the first time. Otherwise one day you might be unpleasantly suprised when some tool destroys something important for you.
One of the first sentences in qmake docs says:
This gives you the following information:qmake generates a Makefile based on the information in a project file.
1. qmake is a tool
2. it needs a project file
3. it generates something called a "Makefile"
And then there is two sentences that you have written:
One sentence from the docs can tell you so many things noone had told you before. Maybe it's time to get a bit more familiar with manuals? It's really nothing personal, I have nothing against you just please don't excuse yourself by saying that nobody told you what some tool did.It's my first qt project and noone tells you what qmake and nmake are supposed to do. So I could be that qmake creates the psql.pro...
Here it is blow by blow:
- Open your Windows Start menu
- Locate the "Qt SDK by Nokia (2010.05)" folder
- Open it and select "Qt Command Prompt"
- In the new command prompt everything is correctly set to find the Qt SDK tools (like qmake and mingw32-make). Test by issuing a "qmake -v" command. You should get a Qmake and Qt version number. If you don't get the version message then stop, you won't get any further.
- Locate the Qt source code in the installed Qt SDK. The default location would be something like "C:\qt\2010.05\qt\src" but you will have to use your knowledge of your system to find it. If you cannot find the sources then stop, you won't get any further.
- In the command prompt change directory to the psql driver directory in the Qt source. The command prompt environment has a variable that points to the Qt directory, QTDIR, so this is the quickest way to get there:
Qt Code:
CD %QTDIR% CD src\plugins\sqldrivers\psql qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro mingw32-makeTo copy to clipboard, switch view to plain text mode
Hey Chris,
thanks for helping me again.
I followed your detailed instructions.
The differences to my last try is, this time I used "Qt command prompt". Last time it was "Windows command prompt". And there was a blank in the installation path of postgresql. I elliminated the blank for plugin building now.
There were no error messages while building the plugin now.
But I haven't understood what to do now to use the plugin.
Okay,
Here in Qt Centre I found this wiki article:
http://www.qtcentre.org/wiki/index.p...ws_using_MinGW
When I compare what I've done with this article, I find the files "qsqlpsql4.dll" and "qsqlpsqld4.dll" in the folder "%QTDIR%\plugins\sqldrivers".
If I load the "qsqlpsql4.dll" with the dependency walker I get the information that there are a few files missing (libpq.dll, mingwm10.dll, libgcc_s_dw2-1.dll, qtcore4.dll, qtsql4.dll).
Tomorrow I'll try to update my enviromental variable paths.
Please tell me if I'm completly wrong.
Greetings
Lot to learn you still have, young padawan. However on the right path you are.
When you started Dependency Walker it was given the default Windows environment PATH, which does not include the Qt bin directories that contain all of the Qt and MingW files listed there. The default environment PATH also does not contain the PostgreSQL binary directory for the PostgreSQL library. Consequently, the Dependency Walker could not load any of these DLLs. If you had launched the Dependency Walker from the "Qt Command Prompt" most of the libraries, except the Postgres ones, would have been found.
You should add the PostgreSQL bin directory to your system PATH. If you develop your program in an environment with the Qt paths set properly such as the Qt Command Prompt or Qt Creator then you should not need to add QT or MingW stuff to the system path. When you deploy you will need to ship the MingW, PostgreSQL and Qt libraries with your application.
Now I added the following paths to the enviroment variable path
But then there are more and more dlls the dependency walker cannot found or with other errorsC:\psql9\bin
C:\qt\2010.05\bin
C:\qt\2010.05\qt\bin
C:\qt\2010.05\mingw\bin
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Just to inform other Newbies who want to connect to PostgreSQL databases as well...
My last-ditch attempt was, just don't care about what the results of the dependency walker are and copied ALL dlls of %postgresdir%\bin.
Now I can load the QPSQL Driver and connect to my postgresql database.
At this point I want to thank the experts of this forum again for trying to help me.
Greetz, wsw
Last edited by WilliamSpiderWeb; 19th March 2011 at 00:09.
Bookmarks