Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, August 2007
Need help with DBus example


Message 1 in thread

I just found this dbus code at http://doc.trolltech.com/qq/qq20-dbus.html.


    #include <QtCore/QtCore>
    #include <QtDBus/QtDBus>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        QDBusConnection bus = QDBusConnection::sessionBus();
        QStringList serviceNames = bus.interface()->
                                   registeredServiceNames();
        qDebug() << serviceNames;
    
        return 0;
    }

I tried to compile this with the command

c++ -I/usr/local/Trolltech/Qt-4.3.1/include -L/usr/local/Trolltech/Qt-4.3.1/lib dbus.cpp  /usr/local/Trolltech/Qt-4.3.1/lib/libQtDBus.so

The program compiles but I get a lot of undefined references to dbus symbols.

Does anyone see what's wrong with my setup?

Thanks,
Dave Feustel

--
 [ signature omitted ] 

Message 2 in thread

> I just found this dbus code at http://doc.trolltech.com/qq/qq20-dbus.html.
> 
> 
>     #include <QtCore/QtCore>
>     #include <QtDBus/QtDBus>
>     
>     int main(int argc, char *argv[])
>     {
>         QCoreApplication app(argc, argv);
>     
>         QDBusConnection bus = QDBusConnection::sessionBus();
>         QStringList serviceNames = bus.interface()->
>                                    registeredServiceNames();
>         qDebug() << serviceNames;
>     
>         return 0;
>     }
> 
> I tried to compile this with the command
> 
> c++ -I/usr/local/Trolltech/Qt-4.3.1/include -L/usr/local/Trolltech/Qt-4.3.1/lib dbus.cpp  /usr/local/Trolltech/Qt-4.3.1/lib/libQtDBus.so
> 
> The program compiles but I get a lot of undefined references to dbus symbols.
> 
> Does anyone see what's wrong with my setup?
> 
> Thanks,
> Dave Feustel

I got this to compile and link using the following makefile:

TT	=	/usr/local/Trolltech
TTI1	=	$TT/Qt-4.3.1/include
TTL1	=	$TT/Qt-4.3.1/lib
TTI0	=	$TT/Qt-4.3.0/include
TTL0	=	$TT/Qt-4.3.0/lib

LIBS	=	-L${TTL1} -L/usr/local/lib ${TTL1}/libQtDBus.so
INC	=	-I${TTI1}
FLAGS	=	-Wall

dbus:	dbus.cpp
	g++ ${FLAGS} ${INC} ${LIBS} -o dbus dbus.cpp

Note that linking fails without the explicit reference to libQtDBus.

I then had to run the command 'dbus-uuidgen --ensure' as root to get
dbus to run without error.

--
 [ signature omitted ]