Hi all,
These are the packages that i have installed:
[cbarmpar@localhost ~]$ rpm -qa | grep qt
qt-x11-4.3.5-2.fc9.i386
qt3-3.3.8b-14.fc9.i386
qt-doc-4.3.5-2.fc9.i386
avahi-qt3-0.6.22-10.fc9.i386
qt-sqlite-4.3.5-2.fc9.i386
dbus-qt-0.70-4.fc9.i386
qt-postgresql-4.3.5-2.fc9.i386
qt-4.3.5-2.fc9.i386
qt-devel-4.3.5-2.fc9.i386
qt-odbc-4.3.5-2.fc9.i386
qt3-MySQL-3.3.8b-14.fc9.i386
i do start the mysql service with this command: /etc/init.d/mysqld start
and i recieve the ok message.
when i am truing to compile the following program :
#include <qapplication.h>
#include <qsqldatabase.h>
int main( int argc, char *argv[] )
{
db->setDatabaseName( "patent" );
db->setUserName( "root" ); // change if your username is different
db->setPassword( "password" ); // change if your password is different
db->setHostName( "localhost" );
// db->setPort( 3306 ); // dont need it in case of localhost
if ( !db->open() )
{
qWarning( "Failed to open database: " + db->lastError().driverText() );
qWarning( db->lastError().databaseText() );
printf( "Error connecting");
return 1;
}
else
{
printf( "Connected " );
}
return 0;
}
#include <qapplication.h>
#include <qsqldatabase.h>
int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
QSqlDatabase *db = QSqlDatabase::addDatabase( "QMYSQL3" );
db->setDatabaseName( "patent" );
db->setUserName( "root" ); // change if your username is different
db->setPassword( "password" ); // change if your password is different
db->setHostName( "localhost" );
// db->setPort( 3306 ); // dont need it in case of localhost
if ( !db->open() )
{
qWarning( "Failed to open database: " + db->lastError().driverText() );
qWarning( db->lastError().databaseText() );
printf( "Error connecting");
return 1;
}
else
{
printf( "Connected " );
}
return 0;
}
To copy to clipboard, switch view to plain text mode
i recieve the following error:
main.cpp:2:26: error: qsqldatabase.h: No such file or directory
main.cpp: In function ‘int main(int, char**)’:
main.
cpp:8: error
: ‘
QSqlDatabase’ was not declared in
this scope
main.cpp:8: error: ‘db’ was not declared in this scope
main.
cpp:8: error
: ‘
QSqlDatabase’ is not a class or
namespacemake: *** [main.o] Error 1
main.cpp:2:26: error: qsqldatabase.h: No such file or directory
main.cpp: In function ‘int main(int, char**)’:
main.cpp:8: error: ‘QSqlDatabase’ was not declared in this scope
main.cpp:8: error: ‘db’ was not declared in this scope
main.cpp:8: error: ‘QSqlDatabase’ is not a class or namespace
make: *** [main.o] Error 1
To copy to clipboard, switch view to plain text mode
i am using qt 4 but it appers to have the mysql qt3 driver is that a problem?
kindest regards
Bookmarks