Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-04-2008, 10:25 PM   #1
Registered: Jan 2006
Distribution: Ubuntu 9.04, Fedora 10
Posts: 76

Rep: Reputation: 17
C/DBus Compilation Problems

I'm trying to write a small program to use the DBus API, but I cannot get it to compile.

#include <dbus/dbus.h>

int main(int arc, char* args[]) {
	DBusError err;
	DBusConnection* conn;

	conn = dbus_bus_get(DBUS_BUS_SESSION, &err);

	return 0;
When I try compiling it using gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include main.c I get the following errors:

main.c:(.text+0x18): undefined reference to `dbus_error_init'
main.c:(.text+0x2b): undefined reference to `dbus_bus_get'
System: Fedora 9; x86

I have the development files installed, and when I edit the files in an editor (Anjuta, or Eclipse/CDT) the functions are suggested by their autocomplete functions, so I assume they should work.

Anybody know what I might be missing, or what I can do to make this work?
Old 10-05-2008, 08:59 AM   #2
Registered: Jan 2006
Distribution: Ubuntu 9.04, Fedora 10
Posts: 76

Original Poster
Rep: Reputation: 17
I wound up getting an answer from somebody else. I was told to run pkg-config --libs dbus-1 and include the output (-L/lib -ldbus-1) in my compilation command. This works, and it all compiles nicely.

gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -L/lib -ldbus-1 main.c is the full line now.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with HAL, dbus, network after Java install... JustMeAgain Debian 6 09-13-2008 05:22 PM
Compilation problems roqin Ubuntu 2 06-16-2008 06:50 PM
C++ compilation problems madhatter301 Programming 4 03-16-2005 05:13 PM
Compilation Problems kamransoomro84 Programming 9 05-04-2004 06:39 PM
X compilation problems da Perp Linux From Scratch 2 07-16-2002 02:46 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:47 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration