PDA

View Full Version : What are the dll's and lib files to be added for my application ??



Gokulnathvc
30th July 2011, 05:51
What are the dll's and lib files to be added for my application to run on the Non-Qt installed machine>>

my source code is::


QString host = QHostInfo::localHostName();
QHostInfo hostinfo = QHostInfo::fromName(host);;
QString address = "";
if (!hostinfo.addresses().isEmpty()) {
QList<QHostAddress> list = hostinfo.addresses();
for(int i=0; i<list.count(); i++)
{
QString ip = list[i].toString();
if(!ip.startsWith("0:") && !ip.startsWith("127."))
{
address.append(ip);
break;
}
}
}


bool ok=false;
QDateTime dateTime = QDateTime::currentDateTime();

QString dd=dateTime.toString("yyyy-MM-dd hh:mm:ss");

QHostInfo info;
QString IPAddress;
QHostAddress Address;
//QMessageBox::information(this,"","" + info.localHostName() + "");
QString hostname=info.localHostName();
//QMessageBox::warning(NULL,"Hostname",hostname,QMessageBox::Ok);



//QMessageBox::warning(NULL,"DriveList",OrigDateTime,QMessageBox::Ok);

QStringList list=QSqlDatabase::drivers();
QString driveList;
for(int i=0;i<list.length();i++)
{
driveList += list[i];
}
//QMessageBox::warning(NULL,"DriveList",driveList,QMessageBox::Ok);
QSqlDatabase db= QSqlDatabase::addDatabase("QMYSQL3");
db.setHostName("172.16.0.1");
db.setDatabaseName("screengrabber");
db.setUserName("scre");
db.setPassword("1234");
ok = db.open();

QString servstr="1";
//servstr.number(serv,2);

/*QMessageBox::warning(NULL,"IPNAME",ipname,QMessageBox::Ok);
QMessageBox::warning(NULL,"datetime",datetime,QMessageBox::Ok);
QMessageBox::warning(NULL,"serv",servstr,QMessageBox::Ok);*/


QSqlQuery querylog(db);
querylog.exec("INSERT INTO service_log (ip_address,date_time, service_status, logged_user)VALUES (?,?,?,?)");
querylog.bindValue(0,address);
querylog.bindValue(1,dd);
querylog.bindValue(2,servstr);
querylog.bindValue(3,hostname);

/*bool qrylog=querylog.exec("INSERT INTO service_log (ip_address,date_time, service_status, logged_user)"
"VALUES ('172.16.0.51','2011-07-28 15:55:09',1,'ramachandran')");*/

bool qrylog= querylog.exec();
/*QString success = querylog.lastError().text();
QMessageBox::warning(NULL,"Error",success,QMessageBox::Ok);
QString execquery=querylog.executedQuery();*/
//QMessageBox::warning(NULL,"Executed Query",execquery,QMessageBox::Ok);

//QHostAddress info1=info.fromName("localhost").addresses().first();

db.close();



for(;;)
{

/*QSqlDatabase db= QSqlDatabase::addDatabase("QMYSQL3");
db.setHostName("172.16.0.1");
db.setDatabaseName("screengrabber");
db.setUserName("scre");
db.setPassword("1234");*/
bool opened = db.open();


originalPixmap =QPixmap();
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
QString strfname;
strfname.sprintf("%d",c);
originalPixmap.save("C:\\Program Files\\image"+strfname+".jpeg","jpeg");
c++;
char Data;
QFile file("C:\\Program Files\\image"+strfname+".jpeg");
file.open(QIODevice::ReadOnly);
//file.seek(0);
int len=file.size();
QByteArray buf;
//buf=file.read(len);
buf=file.readAll();
file.close();
file.remove();
QSqlQuery query;
query.exec("INSERT INTO log (grab_date, ip_address, image,logged_user) "
"VALUES (?,?,?,?)");
query.bindValue(0,dd);
query.bindValue(1,address);
query.bindValue(2,buf);
query.bindValue (3,hostname);
bool qry=query.exec();

int length=buf.length();

//QMessageBox::warning(NULL,"DriveList",strquery,QMessageBox::Ok);

//QString success1 = query.lastError().text();
//QMessageBox::warning(NULL,"Error",success1,QMessageBox::Ok);
//QString execquery1=query.executedQuery();
//QMessageBox::warning(NULL,"Executed Query",execquery1,QMessageBox::Ok);

db.close();


/*QFile newfile("D:\\img.txt");
newfile.open(QIODevice::WriteOnly);
newfile.write(buf);*/

int iSecret, iRandom;
iSecret = rand() % 20 + 1;
iRandom=iSecret*60000;

QMutex mutex;
mutex.lock();
QWaitCondition waitCondition;
waitCondition.wait(&mutex, iRandom);
mutex.unlock();

ChrisW67
30th July 2011, 06:18
Start with the ones you list in your PRO file.

Gokulnathvc
30th July 2011, 06:38
This code works fine in my system, but it fails in the non QT installed machines. I have added the following dlls: libgcc_s_dw2-1.dll,mingwm10.dll,QtCore4.dll,QtCored4.dll,QtGui4 .dll,QtGuid4.dll,QtNetwork4.dll,QtNetworkd4.dll,Qt Sql4.dll,QtSqld4.dll.

It shows no error while running the exe. but i didnt find the value updated in the database. i have installed MYSQL ODBC Driver 5.1 in the system also.
Anything need to be included??

This is my .pro file::


TARGET = screenshotnew
TEMPLATE = app


SOURCES += main.cpp\
qscreenshot.cpp

HEADERS += qscreenshot.h

FORMS += qscreenshot.ui

QT += sql

QT += network


Added after 14 minutes:

I am getting Driver Not Loaded error while running this set up.. But it works fine while running from the QT Creator.

ChrisW67
30th July 2011, 07:18
You should not be deploying the debug libraries or a debug version of your program: no need for QtCored4, QtGuid4, QtNetworkd4, QtSqld4

You need to include the sqldrivers plugins for your database connection. There are plenty of posts in the forum regarding these.

Gokulnathvc
30th July 2011, 07:20
Could you please help me with my code above and the dll's and lib's to be included in this.

ChrisW67
30th July 2011, 07:50
I just did.

Gokulnathvc
30th July 2011, 08:24
How to include the SQL driver plugins?? Please help me..

ChrisW67
30th July 2011, 08:39
Please you try something for yourself before asking for help. What did you actually try in the 30 minutes between my last post and yours?

QODBC for Open Database Connectivity (ODBC) tell you how the plugin is built. It also gives you a hint about where the plugin might be found (the same hint I have already given you). Deploying an Application on Windows tells you about deploying applications and has a section dedicated to plugins. Put the right plugin file in the right subdirectory of your application folder and all is good.

Gokulnathvc
1st August 2011, 07:53
Can anyone help me with the codes above, both cpp file and Pro file. How to build this successfully, It works fine with QT Creator, but while using the exe outside, it says driver not loaded. How to fix this with the above code in it..

gkarthick5
1st August 2011, 07:58
put your mysql plugin dll in a directory called "sqldrivers" and put that folder where you have your exe. It should work fine.

Gokulnathvc
1st August 2011, 08:29
I have tried with the mysql dlls in sqldrivers plugin also, but it says the same" Driver not loaded"

Gokulnathvc
2nd August 2011, 10:21
I have copied all the sql drivers plugins and other dlls into the directory, but still its gives Driver not loaded error. But it works fine in Qt Creator. As an exe it gives the error.

szisziszilvi
2nd August 2011, 10:30
I had much of trouble with this issue before. So first you can try starting the application and give the dlls that it is missing for running. Than if it still cannot run then try using a process monitor - you can monitor what dll-s are in use when running and what your program looks for. pay attention that there are 2 folders in the Qt folder in which you find dlls, but I've forgotten which one was the good one.

Gokulnathvc
2nd August 2011, 10:34
I have added almost all the dll's it shows while running. Now it is not showing any errors, But i have used message box to show whether the connection succeeds or not, in that message box it shows, Driver Not loaded.

gkarthick5
2nd August 2011, 12:42
try using QApplication::addLibraryPath(<PATH_TO_DLLS>) in the main after you create the QApplication(or QCoreApplication) object