Static build for SQL plugin
-
[quote author="SGaist" date="1379794681"]Are you sure the --with-includes and --with-libraries options are valid ? AFAIK it should be -I and -L when calling configure[/quote]
AFAIK these two options used in Postgresql configure file while -l -L used for Qt.
Any way, I'll try to use -l & -L to se if they will affect or not.
-
[quote]Are you sure the —with-includes and —with-libraries options are valid ? AFAIK it should be -I and -L when calling configure
[/quote]
I tried to use -l & -L as you mentioned above but I got this error message. It seems that --with-libraries & --with-includes are the correct options:[code]mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9
$ ./configure --without-zlib --with-openssl -lC:/OpenSSL-Win32/include -LC:/OpenSSL-Win32/lib/MinGW
configure: error: unrecognized option: -lC:/OpenSSL-Win32/include
Try `./configure --help' for more information.mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9[/code]
-
When configuring you have to let a space between -I/-L and the path
-
Did you clean before trying with the space ?
-
[quote author="SGaist" date="1379883992"]Did you clean before trying with the space ?[/quote]
I used "make confclean"
UPDATE: I got: error message:
[code]mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9
$ make confclean
make: *** No rule to make target `confclean'. Stop.[/code] -
Ok... I didn't realize you were trying to build postgresql... You should rather ask them how to do that
-
[quote]
Ok… I didn’t realize you were trying to build postgresql… You should rather ask them how to do that
[/quote]Finally I successfully built libpg (Postgresql client) with OpenSSL but now Qt itself gives me error message after calling ming32-make as following:
[code]g++ -c -include release\qt_pch.h -pipe -fno-keep-inline-dllexport -O2 -std=c++0x
-fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_USING_NAMESPACE -DQT_BUI
LD_SQL_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_
MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECA
TED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_CAST_FROM_ASCII -DNDEBUG -DSQLIT
E_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABL
E_FTS3_PARENTHESIS -DSQLITE_ENABLE_RTREE -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_C
ORE_LIB -I. -I"F:\Postgresql-static\postgresql-9.1.9\src\include" -I"....\inclu
de" -I"....\include\QtSql" -I"....\include" -I"....\include\QtSql" -I"....\i
nclude\QtSql\5.1.1" -I"....\include\QtSql\5.1.1\QtSql" -I"tmp" -I"..\3rdparty\s
qlite" -I"....\include\QtCore" -I"....\include\QtCore" -I"....\include\QtCore
\5.1.1" -I"....\include\QtCore\5.1.1\QtCore" -I".moc\release_static" -I"." -I"C
:\Qt\Qt5.1.1-static-sqlite-pgsql\qtbase\mkspecs\win32-g++" -o .obj\release_stati
c\qsql_psql.o drivers\psql\qsql_psql.cpp
drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such file or direc
tory
#include <libpq-fe.h>
^
compilation terminated.
Makefile.Release:3320: recipe for target '.obj/release_static/qsql_psql.o' faile
d
mingw32-make[3]: *** [.obj/release_static/qsql_psql.o] Error 1
mingw32-make[3]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
/sql'
Makefile:34: recipe for target 'release' failed
mingw32-make[2]: *** [release] Error 2
mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
/sql'
Makefile:207: recipe for target 'sub-sql-make_first' failed
mingw32-make[1]: *** [sub-sql-make_first] Error 2
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
'
makefile:41: recipe for target 'sub-src-make_first' failed
mingw32-make: *** [sub-src-make_first] Error 2[/code]It crystal clear that this issue related to unknown path although I passed the paths during configure step as following:
[code]configure -no-warnings-are-errors -qt-pcre -qt-libpng -ltcg -release -developer-build -static -qt-sql-sqlite -qt-sql-psql -qt-zlib -qt-libjpeg -opengl desktop -nomake examples -nomake tests -I C:/Postgresql-static/postgresql-9.1.9/src/include -L C:/Postgresql-static/postgresql-9.1.9/src/interfaces/libpq[/code]
ls of libpq folder is:
[code]Postgresql-static/postgresql-9.1.9/src/interfaces/libpq > ls *.h
fe-auth.h libpq-events.h libpq-fe.h libpq-int.h pqexpbuffer.h pqsignal.h win32.h[/code]NOTE: libpq-fe.h already exists in C:/Postgresql-static/postgresql-9.1.9/src/interfaces/libpq !!!
-
I fixed the above issue and built Qt successfully by using the following configurations:
[code]configure -no-warnings-are-errors -qt-pcre -qt-libpng -ltcg -release -developer-build -static -qt-sql-sqlite -qt-sql-psql -qt-zlib -qt-libjpeg -opengl desktop -nomake examples -nomake tests -I C:/postgresql-9.1.9/src/include -L C:/postgresql-9.1.9/src/interfaces/libpq -I C:/postgresql-9.1.9/src/interfaces/libpq[/code]
But as soon as I call any SQL class I get linking error although I successfully built Qt and Postgresql by MinGW!
http://pastebin.com/2e8pqnmMI used the following project to test SQL connectivity:
test.pro
[code]QT += core gui sqlgreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++ -lpthread
LIBS += -LC:/postgresql-9.1.9/src/interfaces/libpq -lpq
[/code]main.cpp
[code]QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("192.168.0.74");
db.setPort(5432);
db.setDatabaseName("testDB");
db.setUserName("postgres");
db.setPassword("pass");
if (!db.open())
qDebug() << "Unable to connect!";
else
qDebug() << "connected.";[/code] -
i'm not sure, but i t may be that you need to do this in your PRO file:
LIBS += -LC:/postgresql-9.1.9/src/interfaces/libpq -llibpq -
[quote author="raven-worx" date="1380003684"]i'm not sure, but i t may be that you need to do this in your PRO file:
LIBS += -LC:/postgresql-9.1.9/src/interfaces/libpq -llibpq[/quote]It gives:
[code]c:/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibpq
collect2.exe: error: ld returned 1 exit status
Makefile.Release:82: recipe for target 'release\test.exe' failed
mingw32-make[1]: *** [release\test.exe] Error 1
mingw32-make[1]: Leaving directory 'C:/Users/mbnoimi/Desktop/build-test-Static_PG-Release'
makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
01:59:01: The process "C:\mingw48_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project test (kit: Static PG)
When executing step 'Make'
01:59:01: Elapsed time: 00:04.[/code] -
ok i was wrong then.
According to "this post":http://www.postgresql.org/message-id/Pine.LNX.4.30.0108241344260.677-100000@peter.localdomain you need -lpq, what you already had tried. So it seem this was correct. So the problem needs to be somewhere else.
-
[quote author="raven-worx" date="1380013513"]ok i was wrong then.
According to "this post":http://www.postgresql.org/message-id/Pine.LNX.4.30.0108241344260.677-100000@peter.localdomain you need -lpq, what you already had tried. So it seem this was correct. So the problem needs to be somewhere else.[/quote]
What do you suggest? I emptied my pockets :)
-
Sorry guys but I'm still stuck with this issue.
I successfully built Postgresql's client by MinGW and Qt for with static options for enabling Postgresql but I Qt failed in linking the libraries as mentioned in my post https://qt-project.org/forums/viewreply/143908/
May you give me a hand of help?
-
Did you also add
@QTPLUGIN += qsqlmysql@
to your pro file ?
and
@Q_IMPORT_PLUGIN( qsqlmysql )@
to your main.cpp ?EDIT: corrected macro
-
After adding the lines you've mentioned I got this error:
[code]..\test\main.cpp:5:17: error: expected constructor, destructor, or type conversion before '(' token
QT_IMPORT_PLUGIN( qsqlpsql )[/code]BTW, I never find any *.dll or *.a inside Qt folder where I built it statically!!! so I wonder how these line will link qsqlpsql?
-
Did you build Qt with qt-sql-psql ? (Not -plugin-sql-psql)
-
[quote author="SGaist" date="1380279497"]Did you build Qt with qt-sql-psql ? (Not -plugin-sql-psql)[/quote]
Yes; I built using:
[code]configure -no-warnings-are-errors -qt-pcre -qt-libpng -ltcg -release -developer-build -static -qt-sql-sqlite -qt-sql-psql -qt-zlib -qt-libjpeg -opengl desktop -nomake examples -nomake tests -I C:/postgresql-9.1.9/src/include -L C:/postgresql-9.1.9/src/interfaces/libpq -I C:/postgresql-9.1.9/src/interfaces/libpq[/code] -
Sorry, I made a typo for the import macro... I've corrected the post