jd
29th February 2008, 15:27
Hello,
I have a problem to run my server application, because my application requires a x server. I will not compile with QtGui. Wich library i have included that requieres QtGui ?
Compiler message:
make
make -f Makefile.Debug
make[1]: Entering directory `/home/osadmin/workspace/qconfigcontrol-server'
g++ -c -pipe -fpermissive -g -Wall -W -D_REENTRANT -DQT_SHARED -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/main.o src/main.cpp
g++ -Wl,--no-undefined -o qconfigcontrol-server debug/server.o debug/main.o debug/moc_server.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
make[1]: Leaving directory `/home/osadmin/workspace/qconfigcontrol-server'
server.h
#ifndef SERVER_H_
#define SERVER_H_
#include <QTcpServer>
#include <QByteArray>
#include <QProcess>
class CServer : public QObject {
Q_OBJECT
public:
CServer();
~CServer() {}
private slots:
void sendData( QByteArray data );
private:
typedef struct {
QString filesystem;
QString size;
QString available;
QString used;
QString usedPercent;
QString mountPoint;
} SHardDrive;
QTcpServer *tcpServer;
QProcess *process;
QList<SHardDrive*> disk;
void parseMountPoints();
};
#endif /*SERVER_H_*/
server.cpp
#include "server.h"
#include <QFile>
CServer::CServer() {
tcpServer = new QTcpServer(this);
if (!tcpServer->listen()) {
qWarning("ERROR: Unable to start server\n");
return;
}
qWarning("Status: OK\n");
}
void CServer::parseMountPoints() {
QString cmd("df");
process = new QProcess(this);
process->start(QFile::encodeName(cmd).data(), QStringList() << "-h");
if (!process->waitForFinished()) {
qWarning("ERROR: could not read mount points\n");
return;
}
QString line = process->readAll();
if (line.isEmpty()) {
qWarning("ERROR: no data found\n");
return;
}
QStringList partitionLine = line.split("\n", QString::SkipEmptyParts);
SHardDrive *hdd = NULL;
QStringList partitionSplit;
for (int i=0; i<partitionLine.size(); i++) {
QRegExp rx("/dev/*");
rx.setPatternSyntax(QRegExp::Wildcard);
if (rx.exactMatch(partitionLine[i])) {
partitionSplit = partitionLine[i].split(QRegExp("\\s+"), QString::SkipEmptyParts);
hdd = new SHardDrive;
disk.append(hdd);
hdd->filesystem = partitionSplit[0];
if (partitionSplit.size() < 2) {
partitionSplit = partitionLine[i+1].split(QRegExp("\\s+"), QString::SkipEmptyParts);
hdd->size = partitionSplit[0];
hdd->used = partitionSplit[1];
hdd->available = partitionSplit[2];
hdd->usedPercent = partitionSplit[3];
hdd->mountPoint = partitionSplit[4];
} else {
hdd->size = partitionSplit[1];
hdd->used = partitionSplit[2];
hdd->available = partitionSplit[3];
hdd->usedPercent = partitionSplit[4];
hdd->mountPoint = partitionSplit[5];
}
}
}
delete hdd;
}
void CServer::sendData( QByteArray data ) {
}
main.cpp
#include <QtCore>
#include <QCoreApplication>
#include "server/server.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
CServer server;
return app.exec();
}
so long
jd
I have a problem to run my server application, because my application requires a x server. I will not compile with QtGui. Wich library i have included that requieres QtGui ?
Compiler message:
make
make -f Makefile.Debug
make[1]: Entering directory `/home/osadmin/workspace/qconfigcontrol-server'
g++ -c -pipe -fpermissive -g -Wall -W -D_REENTRANT -DQT_SHARED -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/main.o src/main.cpp
g++ -Wl,--no-undefined -o qconfigcontrol-server debug/server.o debug/main.o debug/moc_server.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
make[1]: Leaving directory `/home/osadmin/workspace/qconfigcontrol-server'
server.h
#ifndef SERVER_H_
#define SERVER_H_
#include <QTcpServer>
#include <QByteArray>
#include <QProcess>
class CServer : public QObject {
Q_OBJECT
public:
CServer();
~CServer() {}
private slots:
void sendData( QByteArray data );
private:
typedef struct {
QString filesystem;
QString size;
QString available;
QString used;
QString usedPercent;
QString mountPoint;
} SHardDrive;
QTcpServer *tcpServer;
QProcess *process;
QList<SHardDrive*> disk;
void parseMountPoints();
};
#endif /*SERVER_H_*/
server.cpp
#include "server.h"
#include <QFile>
CServer::CServer() {
tcpServer = new QTcpServer(this);
if (!tcpServer->listen()) {
qWarning("ERROR: Unable to start server\n");
return;
}
qWarning("Status: OK\n");
}
void CServer::parseMountPoints() {
QString cmd("df");
process = new QProcess(this);
process->start(QFile::encodeName(cmd).data(), QStringList() << "-h");
if (!process->waitForFinished()) {
qWarning("ERROR: could not read mount points\n");
return;
}
QString line = process->readAll();
if (line.isEmpty()) {
qWarning("ERROR: no data found\n");
return;
}
QStringList partitionLine = line.split("\n", QString::SkipEmptyParts);
SHardDrive *hdd = NULL;
QStringList partitionSplit;
for (int i=0; i<partitionLine.size(); i++) {
QRegExp rx("/dev/*");
rx.setPatternSyntax(QRegExp::Wildcard);
if (rx.exactMatch(partitionLine[i])) {
partitionSplit = partitionLine[i].split(QRegExp("\\s+"), QString::SkipEmptyParts);
hdd = new SHardDrive;
disk.append(hdd);
hdd->filesystem = partitionSplit[0];
if (partitionSplit.size() < 2) {
partitionSplit = partitionLine[i+1].split(QRegExp("\\s+"), QString::SkipEmptyParts);
hdd->size = partitionSplit[0];
hdd->used = partitionSplit[1];
hdd->available = partitionSplit[2];
hdd->usedPercent = partitionSplit[3];
hdd->mountPoint = partitionSplit[4];
} else {
hdd->size = partitionSplit[1];
hdd->used = partitionSplit[2];
hdd->available = partitionSplit[3];
hdd->usedPercent = partitionSplit[4];
hdd->mountPoint = partitionSplit[5];
}
}
}
delete hdd;
}
void CServer::sendData( QByteArray data ) {
}
main.cpp
#include <QtCore>
#include <QCoreApplication>
#include "server/server.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
CServer server;
return app.exec();
}
so long
jd