PDA

View Full Version : cross compiling with linux to create a windows app, cant get libpq to link



newbie43
18th December 2010, 16:17
Hi folks
Im using the latest qt and im able to create linux apps and cross compile windows apps on a linux ubuntu system. But now i need my windows app to access a postgresql database that is running on an external linux box. so i added the following to my .pro file

unix:LIBS += -lpq
win32:LIBS += libpqdll.lib

a database connection works ok when compiling for linux but im getting this error when i compile the app for windows.

/usr/lib/gcc/i586-mingw32msvc/4.4.2/../../../../i586-mingw32msvc/bin/ld: cannot find -lpqdll.lib

I know i probably have to download the lib or build the lib from source. Where would i find this library? or do i search for it on the mingw site and just download it and place it in the proper location? Any help would be appreciated. Thanks

wysota
18th December 2010, 16:40
Why don't you use Qt's database plugins? You wouldn't need to link against libpq directly.

newbie43
18th December 2010, 17:11
Yeah i was doing that earlier and i didnt have any of the unix:LIBS += -lpq or win32:LIBS += libpqdll.lib defined in the .pro file and the linux app was connecting just fine because i did have QT += sql, so this means the windows side of things when doing this make distclean && qmake -spec win32-x-g++ && make will connect as well? I tried building the app again for windows without any of the LIBS defined and it doesnt connect to postgres but the linux app does? Do i need a different sql flag of some sort for mingw?

Added after 7 minutes:

I think need some database plugins on my windows side of qt4.7-mingw directory for now ive been just placing my binaries in the c:\qt-4.7-mingw\4.7.1\bin path and they have been running fine there until im ready to learn how to package this stuff up. I see database dlls in the plugins dir but not one for postgresql .

wysota
18th December 2010, 18:22
Yes, you need a Qt PostgreSQL plugin for Windows.